本文整理汇总了Java中com.sun.tools.xjc.outline.ClassOutline类的典型用法代码示例。如果您正苦于以下问题:Java ClassOutline类的具体用法?Java ClassOutline怎么用?Java ClassOutline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassOutline类属于com.sun.tools.xjc.outline包,在下文中一共展示了ClassOutline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1:
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
protected JMethod generateMergeFrom$mergeFrom0(
final ClassOutline classOutline, final JDefinedClass theClass) {
JCodeModel codeModel = theClass.owner();
final JMethod mergeFrom$mergeFrom = theClass.method(JMod.PUBLIC,
codeModel.VOID, "mergeFrom");
{
final JVar left = mergeFrom$mergeFrom.param(Object.class, "left");
final JVar right = mergeFrom$mergeFrom.param(Object.class, "right");
final JBlock body = mergeFrom$mergeFrom.body();
final JVar mergeStrategy = body.decl(JMod.FINAL,
codeModel.ref(MergeStrategy2.class), "strategy",
createMergeStrategy(codeModel));
body.invoke("mergeFrom").arg(JExpr._null()).arg(JExpr._null())
.arg(left).arg(right).arg(mergeStrategy);
}
return mergeFrom$mergeFrom;
}
示例2: run
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
@Override
public boolean run(Outline outline, Options options, ErrorHandler errorHandler) {
// for each generated classes
for (ClassOutline generatedClassOutline : outline.getClasses()) {
JDefinedClass generatedClass = generatedClassOutline.implClass;
if (!isAbstractClass(generatedClass) &&
!generatedClass.fields().isEmpty()) {
boolean commandExecuted = false;
for (Command command : commands.values()) {
if (command.isEnabled()) {
command.editGeneratedClass(generatedClass);
commandExecuted = true;
}
}
if (!commandExecuted) {
defaultCommand.editGeneratedClass(generatedClass);
}
}
}
return true;
}
示例3: run
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
@Override
public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) throws Exception {
PluginImpl clonePlugin = new PluginImpl();
clonePlugin.run(outline, opt, errorHandler);
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
ClassOutline classOutline = outline.getClazz(entry.getValue());
if (isPrism(classOutline)) {
removeConstructors(classOutline);
removeCloneableMethod(classOutline);
removePrivateStaticCopyMethods(classOutline);
createCloneMethod(classOutline);
}
}
return true;
}
示例4: removeCustomGeneratedMethod
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
/**
* remove generated equals methods from classes which extends from prism containers/objects
*/
private void removeCustomGeneratedMethod(Outline outline) {
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
ClassOutline classOutline = outline.getClazz(entry.getValue());
QName qname = getCClassInfoQName(entry.getValue());
if (qname == null || (!hasParentAnnotation(classOutline, A_PRISM_OBJECT)
&& !hasParentAnnotation(classOutline, A_PRISM_CONTAINER))) {
continue;
}
JDefinedClass definedClass = classOutline.implClass;
Iterator<JClass> iterator = definedClass._implements();
while (iterator.hasNext()) {
JClass clazz = iterator.next();
if (clazz.equals(CLASS_MAP.get(Equals.class)) || clazz.equals(CLASS_MAP.get(HashCode.class))) {
iterator.remove();
}
}
boolean isMidpointContainer = hasParentAnnotation(classOutline, A_PRISM_OBJECT);
removeOldCustomGeneratedEquals(classOutline, isMidpointContainer);
removeOldCustomGenerated(classOutline, isMidpointContainer, METHOD_HASH_CODE);
removeOldCustomGenerated(classOutline, isMidpointContainer, METHOD_TO_STRING);
}
}
示例5: removeOldCustomGenerated
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private void removeOldCustomGenerated(ClassOutline classOutline, boolean isPrismObject, String methodName) {
JDefinedClass definedClass = classOutline.implClass;
Iterator<JMethod> methods = definedClass.methods().iterator();
while (methods.hasNext()) {
JMethod method = methods.next();
if (isPrismObject && !hasAnnotation(classOutline, A_PRISM_OBJECT)) {
if (method.name().equals(methodName)) {
methods.remove();
}
} else {
if (method.name().equals(methodName) && method.listParams().length != 0) {
methods.remove();
}
}
}
}
示例6: removeOldCustomGeneratedEquals
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private void removeOldCustomGeneratedEquals(ClassOutline classOutline, boolean isPrismObject) {
JDefinedClass definedClass = classOutline.implClass;
Iterator<JMethod> methods = definedClass.methods().iterator();
while (methods.hasNext()) {
JMethod method = methods.next();
if (isPrismObject && !hasAnnotation(classOutline, A_PRISM_OBJECT)) {
if (method.name().equals(METHOD_EQUALS)) {
methods.remove();
}
} else {
if (method.name().equals(METHOD_EQUALS) && method.listParams().length != 1) {
methods.remove();
}
}
}
}
示例7: createEqualsMethod
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private void createEqualsMethod(ClassOutline classOutline, String baseMethod) {
JDefinedClass definedClass = classOutline.implClass;
JMethod equals = definedClass.getMethod(METHOD_EQUALS, new JType[]{CLASS_MAP.get(Object.class)});
if (equals != null) {
// removeOldCustomGeneratedEquals(classOutline, hasParentAnnotation(classOutline, PRISM_OBJECT)); todo can this be removed?
equals = recreateMethod(equals, definedClass);
} else {
equals = definedClass.method(JMod.PUBLIC, boolean.class, METHOD_EQUALS);
}
equals.annotate(CLASS_MAP.get(Override.class));
JBlock body = equals.body();
JVar obj = equals.listParams()[0];
JBlock ifNull = body._if(obj._instanceof(definedClass).not())._then();
ifNull._return(JExpr.lit(false));
JVar other = body.decl(definedClass, "other", JExpr.cast(definedClass, obj));
JInvocation invocation = JExpr.invoke(baseMethod).invoke(METHOD_EQUIVALENT);
invocation.arg(other.invoke(baseMethod));
body._return(invocation);
}
示例8: createAsPrismContainer
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private void createAsPrismContainer(ClassOutline classOutline, JVar container) {
JDefinedClass definedClass = classOutline.implClass;
JMethod getContainer = definedClass.method(JMod.PUBLIC, CLASS_MAP.get(PrismObject.class),
METHOD_AS_PRISM_CONTAINER);
//create method body
JBlock body = getContainer.body();
JBlock then = body._if(container.eq(JExpr._null()))._then();
JInvocation newContainer = JExpr._new(CLASS_MAP.get(PrismObject.class));
newContainer.arg(JExpr.invoke(METHOD_GET_CONTAINER_NAME));
newContainer.arg(JExpr._this().invoke("getClass"));
// newContainer.arg(JExpr.dotclass(definedClass));
then.assign(container, newContainer);
body._return(container);
}
示例9: addComplextType
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private void addComplextType(Outline outline, Map<String, JFieldVar> namespaceFields) {
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
ClassOutline classOutline = outline.getClazz(entry.getValue());
QName qname = entry.getValue().getTypeName();
if (qname == null) {
continue;
}
JFieldVar var = namespaceFields.get(qname.getNamespaceURI());
if (var != null) {
createQNameDefinition(outline, classOutline.implClass, COMPLEX_TYPE_FIELD_NAME, var, qname);
} else {
createPSFField(outline, classOutline.implClass, COMPLEX_TYPE_FIELD_NAME, qname);
}
}
}
示例10: getComplexTypeToElementName
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private Map<QName, List<QName>> getComplexTypeToElementName(ClassOutline classOutline) {
Map<QName, List<QName>> complexTypeToElementName = new HashMap<QName, List<QName>>();
XSSchemaSet schemaSet = classOutline.target.getSchemaComponent().getRoot();
for (XSSchema schema : schemaSet.getSchemas()) {
Map<String, XSElementDecl> elemDecls = schema.getElementDecls();
for (Entry<String, XSElementDecl> entry : elemDecls.entrySet()) {
XSElementDecl decl = entry.getValue();
XSType xsType = decl.getType();
if (xsType.getName() == null) {
continue;
}
QName type = new QName(xsType.getTargetNamespace(), xsType.getName());
List<QName> qnames = complexTypeToElementName.get(type);
if (qnames == null) {
qnames = new ArrayList<QName>();
complexTypeToElementName.put(type, qnames);
}
qnames.add(new QName(decl.getTargetNamespace(), decl.getName()));
}
}
return complexTypeToElementName;
}
示例11: updateFieldReference
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private boolean updateFieldReference(JFieldVar field, ClassOutline classOutline) {
JMethod getterMethod = recreateGetter(field, classOutline);
annotateMethodWithXmlElement(getterMethod, field);
boolean isList = isList(field.type());
createFieldReferenceGetterBody(field, classOutline, getterMethod.body(), isList);
//setter method update
if (!isList) {
JMethod setterMethod = recreateSetter(field, classOutline);
JVar param = setterMethod.listParams()[0];
createFieldReferenceSetterBody(field, param, setterMethod.body());
} else {
createFieldListCreator(field, classOutline, getterMethod, "createReference");
}
return true;
}
示例12: updateFieldReferenceUse
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private boolean updateFieldReferenceUse(JFieldVar field, ClassOutline classOutline) {
//getter method update
JMethod getterMethod = recreateGetter(field, classOutline);
annotateMethodWithXmlElement(getterMethod, field);
boolean isList = isList(field.type());
createFieldReferenceUseGetterBody(field, classOutline, getterMethod.body(), isList);
//setter method update
if (!isList) {
JMethod setterMethod = recreateSetter(field, classOutline);
createFieldReferenceUseSetterBody(field, classOutline, setterMethod.listParams()[0], setterMethod.body());
} else {
createFieldListCreator(field, classOutline, getterMethod, "createReference");
}
return true;
}
示例13: isFieldReference
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private boolean isFieldReference(JFieldVar field, ClassOutline classOutline) {
CPropertyInfo propertyInfo = classOutline.target.getProperty(field.name());
Collection<? extends CTypeInfo> collection = propertyInfo.ref();
if (collection == null || collection.isEmpty()) {
return false;
}
CTypeInfo info = collection.iterator().next();
if (info instanceof CClassInfo) {
CClassInfo classInfo = (CClassInfo) info;
if (OBJECT_REFERENCE_TYPE.equals(classInfo.getTypeName())) {
return true;
}
}
return false;
}
示例14: createContainerFieldSetterBody
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private void createContainerFieldSetterBody(JFieldVar field, ClassOutline classOutline, JMethod method) {
JVar param = method.listParams()[0];
JBlock body = method.body();
JVar cont;
if (isPrismContainer(param.type(), classOutline.parent())) {
cont = body.decl(CLASS_MAP.get(PrismObject.class), FIELD_CONTAINER_VALUE_LOCAL_VAR_NAME, JOp.cond(param.ne(JExpr._null()),
JExpr.invoke(param, METHOD_AS_PRISM_CONTAINER_VALUE), JExpr._null()));
} else {
cont = body.decl(CLASS_MAP.get(PrismContainerValue.class), FIELD_CONTAINER_VALUE_LOCAL_VAR_NAME,
JOp.cond(param.ne(JExpr._null()), JExpr.invoke(param, METHOD_AS_PRISM_CONTAINER_VALUE), JExpr._null()));
}
JInvocation invocation = body.staticInvoke(CLASS_MAP.get(PrismForJAXBUtil.class),
METHOD_PRISM_UTIL_SET_FIELD_CONTAINER_VALUE);
invocation.arg(JExpr.invoke(METHOD_AS_PRISM_CONTAINER_VALUE));
invocation.arg(JExpr.ref(fieldFPrefixUnderscoredUpperCase(field.name())));
invocation.arg(cont);
}
示例15: createFluentBegin
import com.sun.tools.xjc.outline.ClassOutline; //导入依赖的package包/类
private JMethod createFluentBegin(JFieldVar field, ClassOutline targetClass, ClassOutline fieldsFromClass,
JMethod fluentSetter) {
JType valueClass = getContentType(field);
// e.g. public AssignmentType beginAssignment() {
String methodName = getMethodName(fieldsFromClass, field, "begin");
JMethod beginMethod = targetClass.implClass.method(JMod.PUBLIC, valueClass, methodName);
JBlock body = beginMethod.body();
// AssignmentType value = new AssignmentType();
JVar value = body.decl(valueClass, "value", JExpr._new(valueClass));
// addAssignment(value);
body.invoke(fluentSetter).arg(value);
// return value;
body._return(value);
return beginMethod;
}