本文整理汇总了Java中com.squareup.javawriter.JavaWriter.setIndent方法的典型用法代码示例。如果您正苦于以下问题:Java JavaWriter.setIndent方法的具体用法?Java JavaWriter.setIndent怎么用?Java JavaWriter.setIndent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.javawriter.JavaWriter
的用法示例。
在下文中一共展示了JavaWriter.setIndent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generate() throws IOException {
String qualifiedGeneratedClassName = String.format(Locale.US, "%s.%s", Constants.REALM_PACKAGE_NAME, Constants.DEFAULT_MODULE_CLASS_NAME);
JavaFileObject sourceFile = env.getFiler().createSourceFile(qualifiedGeneratedClassName);
JavaWriter writer = new JavaWriter(new BufferedWriter(sourceFile.openWriter()));
writer.setIndent(" ");
writer.emitPackage(Constants.REALM_PACKAGE_NAME);
writer.emitEmptyLine();
Map<String, Boolean> attributes = new HashMap<String, Boolean>();
attributes.put("allClasses", Boolean.TRUE);
writer.emitAnnotation(RealmModule.class, attributes);
writer.beginType(
qualifiedGeneratedClassName, // full qualified name of the item to generate
"class", // the type of the item
Collections.<Modifier>emptySet(), // modifiers to apply
null); // class to extend
writer.emitEmptyLine();
writer.endType();
writer.close();
}
示例2: generate
import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generate() throws IOException {
String qualifiedGeneratedClassName = String.format(Locale.US, "%s.%sMediator", REALM_PACKAGE_NAME, className);
JavaFileObject sourceFile = processingEnvironment.getFiler().createSourceFile(qualifiedGeneratedClassName);
JavaWriter writer = new JavaWriter(new BufferedWriter(sourceFile.openWriter()));
writer.setIndent(" ");
writer.emitPackage(REALM_PACKAGE_NAME);
writer.emitEmptyLine();
writer.emitImports(
"android.util.JsonReader",
"java.io.IOException",
"java.util.Collections",
"java.util.HashSet",
"java.util.List",
"java.util.Map",
"java.util.HashMap",
"java.util.Set",
"java.util.Iterator",
"java.util.Collection",
"io.realm.internal.ColumnInfo",
"io.realm.internal.RealmObjectProxy",
"io.realm.internal.RealmProxyMediator",
"io.realm.internal.Row",
"io.realm.internal.OsSchemaInfo",
"io.realm.internal.OsObjectSchemaInfo",
"org.json.JSONException",
"org.json.JSONObject"
);
writer.emitEmptyLine();
writer.emitAnnotation(RealmModule.class);
writer.beginType(
qualifiedGeneratedClassName, // full qualified name of the item to generate
"class", // the type of the item
Collections.<Modifier>emptySet(), // modifiers to apply
"RealmProxyMediator"); // class to extend
writer.emitEmptyLine();
emitFields(writer);
emitGetExpectedObjectSchemaInfoMap(writer);
emitCreateColumnInfoMethod(writer);
emitGetFieldNamesMethod(writer);
emitGetSimpleClassNameMethod(writer);
emitNewInstanceMethod(writer);
emitGetClassModelList(writer);
emitCopyToRealmMethod(writer);
emitInsertObjectToRealmMethod(writer);
emitInsertListToRealmMethod(writer);
emitInsertOrUpdateObjectToRealmMethod(writer);
emitInsertOrUpdateListToRealmMethod(writer);
emitCreteOrUpdateUsingJsonObject(writer);
emitCreateUsingJsonStream(writer);
emitCreateDetachedCopyMethod(writer);
writer.endType();
writer.close();
}
示例3: generate
import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generate() throws IOException, UnsupportedOperationException {
JavaFileObject sourceFile = processingEnvironment.getFiler().createSourceFile(qualifiedGeneratedClassName);
JavaWriter writer = new JavaWriter(new BufferedWriter(sourceFile.openWriter()));
// Set source code indent
writer.setIndent(Constants.INDENT);
writer.emitPackage(Constants.REALM_PACKAGE_NAME)
.emitEmptyLine();
List<String> imports = new ArrayList<String>(IMPORTS);
if (!metadata.getBacklinkFields().isEmpty()) {
imports.add("io.realm.internal.UncheckedRow");
}
writer.emitImports(imports)
.emitEmptyLine();
// Begin the class definition
if (suppressWarnings) {
writer.emitAnnotation("SuppressWarnings(\"all\")");
}
writer
.beginType(
qualifiedGeneratedClassName, // full qualified name of the item to generate
"class", // the type of the item
EnumSet.of(Modifier.PUBLIC), // modifiers to apply
qualifiedClassName, // class to extend
"RealmObjectProxy", // interfaces to implement
interfaceName)
.emitEmptyLine();
emitColumnInfoClass(writer);
emitClassFields(writer);
emitInstanceFields(writer);
emitConstructor(writer);
emitInjectContextMethod(writer);
emitPersistedFieldAccessors(writer);
emitBacklinkFieldAccessors(writer);
emitCreateExpectedObjectSchemaInfo(writer);
emitGetExpectedObjectSchemaInfo(writer);
emitCreateColumnInfoMethod(writer);
emitGetSimpleClassNameMethod(writer);
emitGetFieldNamesMethod(writer);
emitCreateOrUpdateUsingJsonObject(writer);
emitCreateUsingJsonStream(writer);
emitCopyOrUpdateMethod(writer);
emitCopyMethod(writer);
emitInsertMethod(writer);
emitInsertListMethod(writer);
emitInsertOrUpdateMethod(writer);
emitInsertOrUpdateListMethod(writer);
emitCreateDetachedCopyMethod(writer);
emitUpdateMethod(writer);
emitToStringMethod(writer);
emitRealmObjectProxyImplementation(writer);
emitHashcodeMethod(writer);
emitEqualsMethod(writer);
// End the class definition
writer.endType();
writer.close();
}
示例4: generate
import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generate() throws IOException {
String qualifiedGeneratedInterfaceName =
String.format(Locale.US, "%s.%s", Constants.REALM_PACKAGE_NAME, Utils.getProxyInterfaceName(className));
JavaFileObject sourceFile = processingEnvironment.getFiler().createSourceFile(qualifiedGeneratedInterfaceName);
JavaWriter writer = new JavaWriter(new BufferedWriter(sourceFile.openWriter()));
writer.setIndent(Constants.INDENT);
writer
.emitPackage(Constants.REALM_PACKAGE_NAME)
.emitEmptyLine()
.beginType(qualifiedGeneratedInterfaceName, "interface", EnumSet.of(Modifier.PUBLIC));
for (VariableElement field : metaData.getFields()) {
if (field.getModifiers().contains(Modifier.STATIC) || (field.getAnnotation(Ignore.class) != null)) {
continue;
}
// The field is neither static nor ignored
String fieldName = field.getSimpleName().toString();
String fieldTypeCanonicalName = field.asType().toString();
writer
.beginMethod(
fieldTypeCanonicalName,
metaData.getInternalGetter(fieldName),
EnumSet.of(Modifier.PUBLIC))
.endMethod();
// MutableRealmIntegers do not have setters.
if (Utils.isMutableRealmInteger(field)) { continue; }
writer
.beginMethod(
"void",
metaData.getInternalSetter(fieldName),
EnumSet.of(Modifier.PUBLIC),
fieldTypeCanonicalName,
"value")
.endMethod();
}
// backlinks are final and have only a getter.
for (Backlink backlink : metaData.getBacklinkFields()) {
writer
.beginMethod(
backlink.getTargetFieldType(),
metaData.getInternalGetter(backlink.getTargetField()),
EnumSet.of(Modifier.PUBLIC))
.endMethod();
}
writer.endType();
writer.close();
}
示例5: generateParser
import com.squareup.javawriter.JavaWriter; //导入方法依赖的package包/类
public void generateParser() throws IOException {
String parserName = MetaTypeNames.constructTypeName(classElement, GeneratedClassNames.PARSER_SUFFIX);
JavaFileObject sourceFile = processingEnv.getFiler().createSourceFile(parserName);
JavaWriter writer = new JavaWriter(sourceFile.openWriter());
writer.setIndent(" ");
writer.emitPackage(processingEnv.getElementUtils().getPackageOf(classElement).getQualifiedName().toString());
writer.emitImports(getStandardImports());
writer.emitEmptyLine();
parsedClassName = writer.compressType(classElement.getQualifiedName().toString());
String jsonObjectParserInterfaceName = JavaWriter.type(JsonObjectParser.class, parsedClassName);
String fromMapUpdaterInterfaceName = JavaWriter.type(InstanceUpdater.class, parsedClassName);
writer.beginType(parserName, "class", EnumSet.of(Modifier.PUBLIC, Modifier.FINAL), null,
jsonObjectParserInterfaceName, fromMapUpdaterInterfaceName);
writer.emitEmptyLine();
writer.emitField(parserName, "INSTANCE", Modifiers.PUBLIC_CONSTANT,
String.format("new %s()", writer.compressType(parserName)));
writer.emitEmptyLine();
// Constructor
writer.beginMethod(null, parserName, Modifiers.PRIVATE);
writer.endMethod();
writer.emitEmptyLine();
initializeAssignments(writer);
writePublicParseJsonObjectMethod(writer);
writer.emitEmptyLine();
writeParseFromJsonObjectMethod(writer);
writer.emitEmptyLine();
writeParseFromReaderMethod(writer);
writer.emitEmptyLine();
writeUpdateFromMapMethod(writer);
writer.emitEmptyLine();
writeGetFieldMethod(writer);
writer.emitEmptyLine();
writeInitializeAndGetFieldMethod(writer);
writer.emitEmptyLine();
writeDoInitializeAndGetFieldMethod(writer);
if (!postCreateChildMethods.isEmpty()) {
// TODO: Only write the methods that we need.
// TODO: Tell block writer whether to write the map or collection parts.
writer.emitEmptyLine();
postCreateChildBlockWriter.writePostCreateChildMethod(writer);
writer.emitEmptyLine();
postCreateChildBlockWriter.writePostCreateCollectionMethod(writer);
writer.emitEmptyLine();
postCreateChildBlockWriter.writePostCreateMapMethod(writer);
}
writer.endType();
writer.close();
}