Java源码示例:com.sun.tools.xjc.model.CValuePropertyInfo

示例1
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);
}
 
示例2
public static TypeUse getTypeUse(ProcessModel processModel,
		CPropertyInfo propertyInfo) {
	if (propertyInfo instanceof CValuePropertyInfo) {
		return ((CValuePropertyInfo) propertyInfo).getTarget();
	} else if (propertyInfo instanceof CAttributePropertyInfo) {
		return ((CAttributePropertyInfo) propertyInfo).getTarget();
	} else {
		final CTypeInfo type = propertyInfo.ref().iterator().next();
		if (type instanceof CBuiltinLeafInfo) {
			if (propertyInfo.getAdapter() != null) {
				return TypeUseFactory.adapt((CBuiltinLeafInfo) type,
						propertyInfo.getAdapter());
			} else {
				return (CBuiltinLeafInfo) type;
			}
		} else if (type instanceof CElementInfo) {
			final CElementInfo elementInfo = (CElementInfo) type;
			return getTypeUse(processModel, elementInfo.getProperty());
		} else {
			throw new AssertionError("Unexpected type.");
		}
	}

}
 
示例3
public TypeUse getTypeUse(C context, CPropertyInfo propertyInfo) {
	if (propertyInfo instanceof CValuePropertyInfo) {
		return ((CValuePropertyInfo) propertyInfo).getTarget();
	} else if (propertyInfo instanceof CAttributePropertyInfo) {
		return ((CAttributePropertyInfo) propertyInfo).getTarget();
	} else {
		final CTypeInfo type = propertyInfo.ref().iterator().next();
		if (type instanceof CBuiltinLeafInfo) {
			if (propertyInfo.getAdapter() != null) {
				return TypeUseFactory.adapt((CBuiltinLeafInfo) type,
						propertyInfo.getAdapter());
			} else {
				return (CBuiltinLeafInfo) type;
			}
		} else if (type instanceof CElementInfo) {
			final CElementInfo elementInfo = (CElementInfo) type;
			return getTypeUse(context, elementInfo.getProperty());
		} else {
			throw new AssertionError("Unexpected type.");
		}
	}

}
 
示例4
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) {
	try {
		for (ClassOutline co : model.getClasses()) {
			List<CPropertyInfo> properties = co.target.getProperties();
			for (CPropertyInfo property : properties) {
				if (property instanceof CElementPropertyInfo) {
					processElement((CElementPropertyInfo) property, co, model);
				} else if (property instanceof CAttributePropertyInfo) {
					processAttribute((CAttributePropertyInfo) property, co, model);
				} else if (property instanceof CValuePropertyInfo) {
					processAttribute((CValuePropertyInfo) property, co, model);
				}
			}
		}
		return true;
	} catch (Exception e) {
		log(e);
		return false;
	}
}
 
示例5
private void processAttribute(CValuePropertyInfo property, ClassOutline clase, Outline model) {
		FieldOutline field = model.getField(property);
		String propertyName = property.getName(false);
		String className = clase.implClass.name();

		log("Attribute " + propertyName + " added to class " + className);
		XSComponent definition = property.getSchemaComponent();
		RestrictionSimpleTypeImpl particle = (RestrictionSimpleTypeImpl) definition;
		XSSimpleType type = particle.asSimpleType();
		JFieldVar var = clase.implClass.fields().get(propertyName);


//		if (particle.isRequired()) {
//			if (!hasAnnotation(var, NotNull.class)) {
//				if (notNullAnnotations) {
//					System.out.println("@NotNull: " + propertyName + " added to class " + className);
//					var.annotate(NotNull.class);
//				}
//			}
//		}

		validAnnotation(type, var, propertyName, className);
		processType(type, var, propertyName, className);
	}
 
示例6
private void postProcessClassInfo(final Model model,
		final CClassInfo classInfo) {
	final List<CPropertyInfo> properties = new ArrayList<CPropertyInfo>(
			classInfo.getProperties());
	for (CPropertyInfo property : properties) {
		property.accept(new CPropertyVisitor<Void>() {

			public Void onElement(CElementPropertyInfo elementProperty) {
				postProcessElementPropertyInfo(model, classInfo,
						elementProperty);
				return null;
			}

			public Void onAttribute(CAttributePropertyInfo attributeProperty) {
				// TODO Auto-generated method stub
				return null;
			}

			public Void onValue(CValuePropertyInfo valueProperty) {
				// TODO Auto-generated method stub
				return null;
			}

			public Void onReference(CReferencePropertyInfo p) {
				postProcessReferencePropertyInfo(model, classInfo, p);
				return null;
			}

		});
	}
}
 
示例7
public U onValue(CValuePropertyInfo valuePropertyInfo) {
	final CNonElement type = context.getGetTypes().getTarget(context,
			valuePropertyInfo);
	if (type instanceof CBuiltinLeafInfo) {
		return onBuiltinValue(valuePropertyInfo);
	} else if (type instanceof CEnumLeafInfo) {
		return onEnumValue(valuePropertyInfo);
	} else {
		return onOtherValue(valuePropertyInfo);
	}
}
 
示例8
public U onBuiltinValue(CValuePropertyInfo valuePropertyInfo) {
	return !valuePropertyInfo.isCollection() ? classifier
			.onSingleBuiltinValue(valuePropertyInfo) : classifier
			.onCollectionBuiltinValue(valuePropertyInfo);
}
 
示例9
public U onEnumValue(CValuePropertyInfo valuePropertyInfo) {
	return !valuePropertyInfo.isCollection() ? classifier
			.onSingleEnumValue(valuePropertyInfo) : classifier
			.onCollectionEnumValue(valuePropertyInfo);
}
 
示例10
public U onOtherValue(CValuePropertyInfo valuePropertyInfo) {
	return !valuePropertyInfo.isCollection() ? classifier
			.onSingleOtherValue(valuePropertyInfo) : classifier
			.onCollectionOtherValue(valuePropertyInfo);
}
 
示例11
public CNonElement getTarget(C context, CValuePropertyInfo propertyInfo) {
	return propertyInfo.getTarget();
}
 
示例12
public Collection<CPropertyInfo> onSingleBuiltinValue(
		CValuePropertyInfo valuePropertyInfo) {
	return context.getWrapSingleBuiltinValue().process(context,
			valuePropertyInfo);
}
 
示例13
public Collection<CPropertyInfo> onSingleEnumValue(
		CValuePropertyInfo valuePropertyInfo) {
	return context.getWrapSingleEnumValue().process(context,
			valuePropertyInfo);
}
 
示例14
public Collection<CPropertyInfo> onSingleOtherValue(
		CValuePropertyInfo valuePropertyInfo) {
	logger.error("[" + valuePropertyInfo.getName(true)
			+ "] is a single other value. See issue #60.");
	return Collections.emptyList();
}
 
示例15
public Collection<CPropertyInfo> onCollectionBuiltinValue(
		CValuePropertyInfo valuePropertyInfo) {
	return context.getWrapCollectionBuiltinValue().process(context,
			valuePropertyInfo);
}
 
示例16
public Collection<CPropertyInfo> onCollectionEnumValue(
		CValuePropertyInfo valuePropertyInfo) {
	return context.getWrapCollectionEnumValue().process(context,
			valuePropertyInfo);
}
 
示例17
public Collection<CPropertyInfo> onCollectionOtherValue(
		CValuePropertyInfo valuePropertyInfo) {
	logger.error("[" + valuePropertyInfo.getName(true)
			+ "] is a collection other value. See issue #63.");
	return Collections.emptyList();
}
 
示例18
public V onSingleBuiltinValue(CValuePropertyInfo valuePropertyInfo); 
示例19
public V onSingleEnumValue(CValuePropertyInfo valuePropertyInfo); 
示例20
public V onSingleOtherValue(CValuePropertyInfo valuePropertyInfo); 
示例21
public V onCollectionBuiltinValue(CValuePropertyInfo valuePropertyInfo); 
示例22
public V onCollectionEnumValue(CValuePropertyInfo valuePropertyInfo); 
示例23
public V onCollectionOtherValue(CValuePropertyInfo valuePropertyInfo); 
示例24
public CNonElement getTarget(C context, CValuePropertyInfo propertyInfo);