本文整理了Java中org.codehaus.enunciate.contract.jaxb.Accessor
类的一些代码示例,展示了Accessor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Accessor
类的具体详情如下:
包路径:org.codehaus.enunciate.contract.jaxb.Accessor
类名称:Accessor
[英]An accessor for a field or method value into a type.
[中]字段或方法值到类型的访问器。
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
/**
* Returns the accessor for the XML id, or null if none was found or if this isn't an Xml IDREF accessor.
*
* @return The accessor, or null.
*/
public MemberDeclaration getAccessorForXmlID() {
if (isXmlIDREF()) {
TypeMirror accessorType = getBareAccessorType();
if (accessorType instanceof ClassType) {
return getXmlIDAccessor((ClassType) accessorType);
}
}
return null;
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
/**
* Whether this accessor is an MTOM attachment.
*
* @return Whether this accessor is an MTOM attachment.
*/
public boolean isMTOMAttachment() {
return (getAnnotation(XmlInlineBinaryData.class) == null) && (KnownXmlType.BASE64_BINARY.getQname().equals(getBaseType().getQname()));
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-java-client
@Override
public String convert(Accessor accessor) throws TemplateModelException {
if (!accessor.isXmlList() && !accessor.isAdapted() && accessor.getBareAccessorType() instanceof InterfaceType) {
if (accessor.isCollectionType()) {
return "java.util.List<Object>";
}
else {
return "Object";
}
}
return super.convert(accessor);
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-full
/**
* The bare (i.e. unwrapped) type of the accessor.
*
* @return The bare type of the accessor.
*/
public TypeMirror getBareAccessorType() {
return isCollectionType() ? getCollectionItemType() : getAccessorType();
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
/**
* The base xml type of the accessor. The base type is either:
* <p/>
* <ol>
* <li>The xml type of the accessor type.</li>
* <li>The xml type of the component type of the accessor type if the accessor
* type is a collection type.</li>
* </ol>
*
* @return The base type.
*/
public XmlType getBaseType() {
//first check to see if the base type is dictated by a specific annotation.
if (isXmlID()) {
return KnownXmlType.ID;
}
if (isXmlIDREF()) {
return KnownXmlType.IDREF;
}
if (isSwaRef()) {
return KnownXmlType.SWAREF;
}
try {
XmlType xmlType = XmlTypeFactory.findSpecifiedType(this);
return (xmlType != null) ? xmlType : XmlTypeFactory.getXmlType(getAccessorType());
}
catch (XmlTypeException e) {
throw new ValidationException(getPosition(), "Accessor " + getName() + " of " + getTypeDefinition().getQualifiedName() + ": " + e.getMessage());
}
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
/**
* Get the resolved accessor type for this accessor.
*
* @return the resolved accessor type for this accessor.
*/
public TypeMirror getResolvedAccessorType() {
TypeMirror accessorType = getAccessorType();
if (isAdapted()) {
accessorType = getAdapterType().getAdaptingType(accessorType);
}
return accessorType;
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-full
/**
* The base xml type of the accessor. The base type is either:
* <p/>
* <ol>
* <li>The xml type of the accessor type.</li>
* <li>The xml type of the component type of the accessor type if the accessor
* type is a collection type.</li>
* </ol>
*
* @return The base type.
*/
public XmlType getBaseType() {
//first check to see if the base type is dictated by a specific annotation.
if (isXmlID()) {
return KnownXmlType.ID;
}
if (isXmlIDREF()) {
return KnownXmlType.IDREF;
}
if (isSwaRef()) {
return KnownXmlType.SWAREF;
}
try {
XmlType xmlType = XmlTypeFactory.findSpecifiedType(this);
return (xmlType != null) ? xmlType : XmlTypeFactory.getXmlType(getAccessorType());
}
catch (XmlTypeException e) {
throw new ValidationException(getPosition(), e.getMessage());
}
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
public ValidationResult validateAccessor(Accessor accessor) {
ValidationResult result = new ValidationResult();
if (accessor.getDelegate() instanceof PropertyDeclaration) {
PropertyDeclaration property = (PropertyDeclaration) accessor.getDelegate();
DecoratedMethodDeclaration getter = property.getGetter();
DecoratedMethodDeclaration setter = property.getSetter();
if ((accessor.isXmlIDREF()) && (accessor.getAccessorForXmlID() == null)) {
if (this.disabledRules.contains("jaxb.xmlidref.references.xmlid")) {
result.addError(accessor, "An XML IDREF must have a base type that references another type that has an XML ID.");
if (accessor.isReferencesQNameEnum()) {
XmlType baseType = accessor.getBaseType();
if (baseType == null || (!KnownXmlType.QNAME.getQname().equals(baseType.getQname()) && !KnownXmlType.ANY_URI.getQname().equals(baseType.getQname()) && !KnownXmlType.STRING.getQname().equals(baseType.getQname()))) {
result.addError(accessor, "An accessor that references a QName enumeration must return QName or URI.");
TypeMirror enumRef = accessor.getQNameEnumRef();
if (!(enumRef instanceof EnumType) || ((EnumType) enumRef).getDeclaration() == null || ((DeclaredType) enumRef).getDeclaration().getAnnotation(XmlQNameEnum.class) == null) {
result.addError(accessor, "A QName enum reference must reference an enum type annotated with @org.codehaus.enunciate.qname.XmlQNameEnum.");
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
/**
* Whether the accessor type is a collection type.
*
* @return Whether the accessor type is a collection type.
*/
public boolean isCollectionType() {
if (isXmlList()) {
return false;
}
DecoratedTypeMirror accessorType;
if (isAdapted()) {
accessorType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(getAdapterType().getAdaptingType(getAccessorType()));
}
else {
accessorType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(getAccessorType());
}
if (accessorType.isArray()) {
TypeMirror componentType = ((ArrayType) accessorType).getComponentType();
//special case for byte[]
return !(componentType instanceof PrimitiveType) || !(((PrimitiveType) componentType).getKind() == PrimitiveType.Kind.BYTE);
}
return accessorType.isCollection();
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-full
public ValidationResult validateAccessor(Accessor accessor) {
ValidationResult result = new ValidationResult();
if (accessor.getDelegate() instanceof PropertyDeclaration) {
PropertyDeclaration property = (PropertyDeclaration) accessor.getDelegate();
DecoratedMethodDeclaration getter = property.getGetter();
DecoratedMethodDeclaration setter = property.getSetter();
if ((getter != null) && (setter != null)) {
//find all JAXB annotations that are on both the setter and the getter...
Map<String, AnnotationMirror> getterAnnotations = getter.getAnnotations();
Map<String, AnnotationMirror> setterAnnotations = setter.getAnnotations();
for (String annotation : getterAnnotations.keySet()) {
if ((annotation.startsWith(XmlElement.class.getPackage().getName())) && (setterAnnotations.containsKey(annotation))) {
result.addError(setter.getPosition(), "'" + annotation + "' is on both the getter and setter.");
}
}
}
else {
result.addError(accessor.getPosition(), "A property accessor needs both a setter and a getter.");
}
}
if ((accessor.isXmlIDREF()) && (accessor.getAccessorForXmlID() == null)) {
result.addError(accessor.getPosition(), "An XML IDREF must have a base type that references another type that has an XML ID.");
}
return result;
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-c
@Override
public String convert(Accessor accessor) throws TemplateModelException {
if (accessor.isXmlIDREF()) {
return "xmlChar";
}
else if (accessor.isXmlList()) {
return "xmlChar";
}
return super.convert(accessor);
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-ruby
@Override
public String convert(Accessor accessor) throws TemplateModelException {
if (accessor.isXmlIDREF()) {
return "String";
}
return super.convert(accessor);
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-full
public void validateTypeDefinition(TypeDefinition typeDef, ValidationResult result) {
ArrayList<Accessor> accessors = new ArrayList<Accessor>();
accessors.addAll(typeDef.getAttributes());
accessors.add(typeDef.getValue());
accessors.addAll(typeDef.getElements());
for (Accessor accessor : accessors) {
if (accessor != null) {
if ((accessor.getAnnotation(XmlIDREF.class) != null) && (accessor.getAnnotation(XmlList.class) != null)) {
result.addError(accessor.getPosition(), "The xfire client code currently doesn't support @XmlList and @XmlIDREF annotations together.");
}
TypeMirror accessorType = accessor.getBareAccessorType();
if (accessorType instanceof DeclaredType) {
String accessorTypeFQN = ((DeclaredType) accessorType).getDeclaration().getQualifiedName();
if (java.awt.Image.class.getName().equals(accessorTypeFQN)) {
result.addError(accessor.getPosition(), "xfire-client module doesn't yet support handling java.awt.Image.");
}
else if (javax.xml.transform.Source.class.getName().equals(accessorTypeFQN)) {
result.addError(accessor.getPosition(), "xfire-client module doesn't yet support handling javax.xml.transform.Source.");
}
}
}
}
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-full
TypeMirror typeMirror = unwrapComponentType(accessor.getAccessorType());
XmlSchemaType schemaType = accessor.getAnnotation(XmlSchemaType.class);
PackageDeclaration pckg = accessor.getDeclaringType().getPackage();
String packageName = pckg.getQualifiedName();
HashMap<String, XmlSchemaType> explicitTypes = EXPLICIT_ELEMENTS_BY_PACKAGE.get(packageName);
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
/**
* Whether this accessor is specified as an xml list.
*
* @return Whether this accessor is specified as an xml list.
*/
public boolean isXmlList() {
return getAnnotation(XmlList.class) != null;
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-c
DecoratedTypeMirror accessorType = (DecoratedTypeMirror) ((Accessor) unwrapped).getBareAccessorType();
unwrapped = ((Accessor) unwrapped).getBaseType();
代码示例来源:origin: org.codehaus.enunciate/enunciate-xfire-client
public void validateTypeDefinition(TypeDefinition typeDef, ValidationResult result) {
ArrayList<Accessor> accessors = new ArrayList<Accessor>();
accessors.addAll(typeDef.getAttributes());
accessors.add(typeDef.getValue());
accessors.addAll(typeDef.getElements());
for (Accessor accessor : accessors) {
if (accessor != null) {
if ((accessor.getAnnotation(XmlIDREF.class) != null) && (accessor.getAnnotation(XmlList.class) != null)) {
result.addError(accessor, "The xfire client code currently doesn't support @XmlList and @XmlIDREF annotations together.");
}
TypeMirror accessorType = accessor.getBareAccessorType();
if (accessorType instanceof DeclaredType) {
String accessorTypeFQN = ((DeclaredType) accessorType).getDeclaration().getQualifiedName();
if (java.awt.Image.class.getName().equals(accessorTypeFQN)) {
result.addError(accessor, "xfire-client module doesn't yet support handling java.awt.Image.");
}
else if (javax.xml.transform.Source.class.getName().equals(accessorTypeFQN)) {
result.addError(accessor, "xfire-client module doesn't yet support handling javax.xml.transform.Source.");
}
}
}
}
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
/**
* Whether this accessor is a swa ref.
*
* @return Whether this accessor is a swa ref.
*/
public boolean isSwaRef() {
return (getAnnotation(XmlAttachmentRef.class) != null)
&& (getAccessorType() instanceof DeclaredType)
&& (((DeclaredType) getAccessorType()).getDeclaration() != null)
&& ("javax.activation.DataHandler".equals(((DeclaredType) getAccessorType()).getDeclaration().getQualifiedName()));
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-full
/**
* Whether this accessor consists of binary data.
*
* @return Whether this accessor consists of binary data.
*/
public boolean isBinaryData() {
return isSwaRef() || KnownXmlType.BASE64_BINARY.getQname().equals(getBaseType().getQname());
}
代码示例来源:origin: org.codehaus.enunciate/enunciate-core
/**
* Whether this access is a QName type.
*
* @return Whether this access is a QName type.
*/
public boolean isQNameType() {
return getBaseType() == KnownXmlType.QNAME;
}
内容来源于网络,如有侵权,请联系作者删除!