com.sun.xml.xsom.XSComponent Java Examples

The following examples show how to use com.sun.xml.xsom.XSComponent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractAdaptPropertyInfo.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CPropertyInfo createAttributePropertyInfo(String propertyName,
		XSComponent source, TypeUse propertyType, QName propertyQName,
		CollectionMode collectionMode, CCustomizations customizations) {

	final TypeUse typeUse = collectionMode.isRepeated() ?

	new DefaultTypeUse(propertyType.getInfo(), true,
			propertyType.idUse(), propertyType.getExpectedMimeType(),
			propertyType.getAdapterUse()) : propertyType;

	final CAttributePropertyInfo propertyInfo = new CAttributePropertyInfo(
			propertyName, source,

			customizations, null, propertyQName, typeUse, typeUse.getInfo()
					.getTypeName(), false);
	return propertyInfo;
}
 
Example #2
Source File: CreateTypeInfoProducer.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public TypeInfoProducer<T, C> visitBuiltinLeafInfo(MBuiltinLeafInfo<T, C> info) {

		final O origin = this.originated.getOrigin();

		final List<QName> simpleTypeNames = new LinkedList<QName>();
		if (origin instanceof SchemaComponentAware) {
			final XSComponent component = ((SchemaComponentAware) origin).getSchemaComponent();
			if (component != null) {
				final CollectSimpleTypeNamesVisitor visitor = new CollectSimpleTypeNamesVisitor();
				component.visit(visitor);
				simpleTypeNames.addAll(visitor.getTypeNames());
			}
		}

		simpleTypeNames.add(info.getTypeName());

		for (QName candidateName : simpleTypeNames) {
			final TypeInfoProducer<T, C> typeInfoProducer = XSD_TYPE_MAPPING.get(candidateName);
			if (typeInfoProducer != null) {
				return typeInfoProducer;
			}
		}
		return null;
	}
 
Example #3
Source File: AbstractAdaptPropertyInfo.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CPropertyInfo createElementPropertyInfo(String propertyName,
		XSComponent source, TypeUse propertyType, QName propertyQName,
		CollectionMode collectionMode, CCustomizations customizations) {

	final CNonElement propertyTypeInfo = propertyType.getInfo();

	final CElementPropertyInfo propertyInfo = new CElementPropertyInfo(
			propertyName, collectionMode, propertyTypeInfo.idUse(),
			propertyTypeInfo.getExpectedMimeType(), source, customizations,
			null, true);

	final CTypeRef typeRef = new CTypeRef(propertyTypeInfo, propertyQName,
			propertyTypeInfo.getTypeName(), false, null);

	propertyInfo.setAdapter(propertyType.getAdapterUse());

	propertyInfo.getTypes().add(typeRef);
	return propertyInfo;
}
 
Example #4
Source File: CreateTypeInfoCompiler.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public TypeInfoCompiler<T, C> visitBuiltinLeafInfo(MBuiltinLeafInfo<T, C> info) {

		final O origin = this.originated.getOrigin();

		final List<QName> simpleTypeNames = new LinkedList<QName>();
		if (origin instanceof SchemaComponentAware) {
			final XSComponent component = ((SchemaComponentAware) origin).getSchemaComponent();
			if (component != null) {
				final CollectSimpleTypeNamesVisitor visitor = new CollectSimpleTypeNamesVisitor();
				component.visit(visitor);
				simpleTypeNames.addAll(visitor.getTypeNames());
			}
		}

		simpleTypeNames.add(info.getTypeName());

		for (QName candidateName : simpleTypeNames) {
			final TypeInfoCompiler<T, C> typeInfoCompiler = XSD_TYPE_MAPPING.get(candidateName);
			if (typeInfoCompiler != null) {
				return typeInfoCompiler;
			}
		}
		return null;
	}
 
Example #5
Source File: AdaptBuiltinTypeUse.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public TypeUse process(ProcessModel context, CPropertyInfo propertyInfo) {
	// propertyInfo.g
	final TypeUse type = context.getGetTypes().getTypeUse(context,
			propertyInfo);
	final XSComponent schemaComponent = propertyInfo.getSchemaComponent();

	if (schemaComponent != null) {
		final List<QName> typeNames = TypeUtils
				.getTypeNames(schemaComponent);

		for (QName typeName : typeNames) {
			final PropertyType propertyType = new PropertyType(type,
					typeName);
			if (adapters.containsKey(propertyType)) {
				final TypeUse createPropertyInfos = adapters
						.get(propertyType);
				return createPropertyInfos;
			}
		}
		return adapters.get(new PropertyType(type));

	} else {
		return adapters.get(new PropertyType(type));
	}
}
 
Example #6
Source File: SchemaAnnotationUtils.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
private static XSAnnotation resolveXSAnnotation(XSComponent schemaComponent) {
    final XSAnnotation annotation;
    //<xs:complexType name="MyType">
    //		<xs:attribute name="someAttribute" use="required">
    //			<xs:annotation>
    //				<xs:documentation>This is some text</xs:documentation>
    if (schemaComponent instanceof AttributeUseImpl) {
        annotation = ((AttributeUseImpl) schemaComponent).getDecl().getAnnotation();
    }
    // <xs:complexType name="MyType">
    //		<xs:element name="someAttribute" type="stCom:TInterdepStatementHeader" minOccurs="0">
    //			<xs:annotation>
    //				<xs:documentation>This is some text</xs:documentation>
    else if (schemaComponent instanceof ParticleImpl) {
        annotation = (((ParticleImpl) schemaComponent).getTerm()).getAnnotation();
    } else {
        annotation = schemaComponent.getAnnotation();
    }
    return annotation;
}
 
Example #7
Source File: XSFunctionApplier.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public T apply(Object target) {
	Validate.notNull(target);
	if (target instanceof XSComponent) {
		return ((XSComponent) target).apply(f);
	} else if (target instanceof SchemaComponentAware) {
		final XSComponent schemaComponent = ((SchemaComponentAware) target)
				.getSchemaComponent();
		if (schemaComponent == null) {
			return null;
		} else {
			return schemaComponent.apply(f);
		}
	} else {
		return null;
	}
}
 
Example #8
Source File: SCDImpl.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Iterator<XSComponent> select(Iterator<? extends XSComponent> contextNode) {
    Iterator<XSComponent> nodeSet = (Iterator)contextNode;

    int len = steps.length;
    for( int i=0; i<len; i++ ) {
        if(i!=0 && i!=len-1 && !steps[i-1].axis.isModelGroup() && steps[i].axis.isModelGroup()) {
            // expand the current nodeset by adding abbreviatable complex type and model groups.
            // note that such expansion is not allowed to occure in in between model group axes.

            // TODO: this step is not needed if the next step is known not to react to
            // complex type nor model groups, such as, say Axis.FACET
            nodeSet = new Iterators.Unique<XSComponent>(
                new Iterators.Map<XSComponent,XSComponent>(nodeSet) {
                    protected Iterator<XSComponent> apply(XSComponent u) {
                        return new Iterators.Union<XSComponent>(
                            Iterators.singleton(u),
                            Axis.INTERMEDIATE_SKIP.iterator(u) );
                    }
                }
            );
        }
        nodeSet = steps[i].evaluate(nodeSet);
    }

    return nodeSet;
}
 
Example #9
Source File: Step.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Evaluate this step against the current node set
 * and returns matched nodes.
 */
public final Iterator<T> evaluate(Iterator<XSComponent> nodeSet) {
    // list up the whole thing
    Iterator<T> r = new Iterators.Map<T,XSComponent>(nodeSet) {
        protected Iterator<? extends T> apply(XSComponent contextNode) {
            return filter(axis.iterator(contextNode));
        }
    };

    // avoid duplicates
    r = new Iterators.Unique<T>(r);

    if(predicate>=0) {
        T item=null;
        for( int i=predicate; i>0; i-- ) {
            if(!r.hasNext())
                return Iterators.empty();
            item = r.next();
        }
        return new Iterators.Singleton<T>(item);
    }

    return r;
}
 
Example #10
Source File: AbstractAxisImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Default implementation that simply delegate sto {@link #iterator(XSComponent)}
 */
public Iterator<T> iterator(Iterator<? extends XSComponent> contextNodes) {
    return new Iterators.Map<T,XSComponent>(contextNodes) {
        protected Iterator<? extends T> apply(XSComponent u) {
            return iterator(u);
        }
    };
}
 
Example #11
Source File: XJCCMElementTypeRefOrigin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public XJCCMElementTypeRefOrigin(CElementPropertyInfo source,
		CTypeRef typeRef) {
	super(source, typeRef);
	final XSComponent schemaComponent = source.getSchemaComponent();
	if (schemaComponent != null) {
		final FindXSElementDeclVisitor visitor = new FindXSElementDeclVisitor(
				typeRef.getTagName());
		schemaComponent.visit(visitor);
		this.component = visitor.getElementDecl();
	} else {
		this.component = null;
	}
}
 
Example #12
Source File: XJCCMInfoFactory.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private XSAttributeUse getAttributeUse(CAttributePropertyInfo propertyInfo) {
	final XSComponent schemaComponent = propertyInfo.getSchemaComponent();
	if (schemaComponent instanceof XSAttributeUse) {
		return (XSAttributeUse) schemaComponent;
	} else {
		return null;
	}
}
 
Example #13
Source File: SimpleTypeAnalyzer.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Long getMinLength(XSComponent component) {
	if (component == null) {
		return null;
	} else {
		return component.apply(new MinLengthAnalyzer());
	}
}
 
Example #14
Source File: SchemaImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Collection<XSComponent> select(String scd, NamespaceContext nsContext) {
    try {
        return SCD.create(scd,nsContext).select(this);
    } catch (ParseException e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example #15
Source File: SchemaImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public XSComponent selectSingle(String scd, NamespaceContext nsContext) {
    try {
        return SCD.create(scd,nsContext).selectSingle(this);
    } catch (ParseException e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example #16
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void visit(XSModelGroup mg, List<XSComponent> r) {
    // since model groups never form a cycle, no cycle check is needed
    r.add(mg);
    for (XSParticle p : mg) {
        XSModelGroup child = p.getTerm().asModelGroup();
        if(child!=null)
            visit(child,r);
    }
}
 
Example #17
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Iterate all descendant model groups of the given model group, including itself.
 */
private Iterator<XSComponent> descendants(XSModelGroup mg) {
    // TODO: write a tree iterator
    // for now, we do it eagerly because I'm lazy
    List<XSComponent> r = new ArrayList<XSComponent>();
    visit(mg,r);
    return r.iterator();
}
 
Example #18
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Iterator<XSComponent> elementDecl(XSElementDecl decl) {
    XSComplexType ct = decl.getType().asComplexType();
    if(ct==null)
        return empty();
    else {
        // also pick up model groups inside this complex type
        return new Iterators.Union<XSComponent>(singleton(ct),complexType(ct));
    }
}
 
Example #19
Source File: ModelBuilder.java    From mxjc with MIT License 5 votes vote down vote up
/**
 * Helper to get xsdoc from schema component
 * 
 * @param xsComp
 *            ,XSComponent
 * @return doc string
 */
public static String getDocumentation(XSComponent xsComp) {
	if (xsComp == null)
		return null;
	XSAnnotation xsa = xsComp.getAnnotation();
	if (xsa != null && xsa.getAnnotation() != null) {
		String docComment = ((BindInfo) xsa.getAnnotation())
				.getDocumentation();
		return docComment;
	}
	return null;
}
 
Example #20
Source File: SimpleTypeAnalyzer.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Long getMaxLength(XSComponent component) {
	if (component == null) {
		return null;
	} else {
		return component.apply(new MaxLengthAnalyzer());
	}
}
 
Example #21
Source File: SimpleTypeAnalyzer.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Long getLength(XSComponent component) {
	if (component == null) {
		return null;
	} else {
		return component.apply(new LengthAnalyzer());
	}
}
 
Example #22
Source File: SimpleTypeAnalyzer.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Long getTotalDigits(XSComponent component) {
	if (component == null) {
		return null;
	} else {
		return component.apply(new TotalDigitsAnalyzer());
	}
}
 
Example #23
Source File: SimpleTypeAnalyzer.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static Long getFractionDigits(XSComponent component) {
	if (component == null) {
		return null;
	} else {
		return component.apply(new FractionDigitsAnalyzer());
	}
}
 
Example #24
Source File: EpisodeBuilder.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
public OutlineAdaptor(final XSComponent schemaComponent, final OutlineType outlineType,
                      final String implName, final String packageName) {
	this.schemaComponent = schemaComponent;
	this.outlineType = outlineType;
	this.implName = implName;
	this.packageName = packageName;
}
 
Example #25
Source File: EpisodeBuilder.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
public OutlineAdaptor(final XSComponent schemaComponent, final OutlineType outlineType,
                      final JDefinedClass javaType) {
	this.schemaComponent = schemaComponent;
	this.outlineType = outlineType;
	this.implName = javaType.fullName();
	this.packageName = javaType.getPackage().name();
}
 
Example #26
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private String getCustomPropertyName(final XSComponent component) {
	if (component.getAnnotation() != null && (component.getAnnotation().getAnnotation() instanceof BindInfo)) {
		final BindInfo bindInfo = (BindInfo) component.getAnnotation().getAnnotation();
		final BIProperty biProperty = bindInfo.get(BIProperty.class);
		if (biProperty != null) {
			final String customPropertyName = biProperty.getPropertyName(false);
			return customPropertyName != null ? customPropertyName : null;
		}
	}
	return null;
}
 
Example #27
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private static XSComplexType getTypeDefinition(final XSComponent xsTypeComponent) {
	if (xsTypeComponent instanceof XSAttContainer) {
		return (XSComplexType) xsTypeComponent;
	} else if (xsTypeComponent instanceof XSElementDecl) {
		return ((XSElementDecl) xsTypeComponent).getType().asComplexType();
	} else {
		return null;
	}
}
 
Example #28
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private String getConstantName(final FieldOutline fieldOutline) {
	final XSComponent schemaComponent = fieldOutline.getPropertyInfo().getSchemaComponent();
	if (!this.fixedAttributeAsConstantProperty) return null;
	if (schemaComponent instanceof XSAttributeDecl) {
		return ((XSAttributeDecl)schemaComponent).getFixedValue() != null ? fieldOutline.parent().parent().getModel().getNameConverter().toConstantName(((XSAttributeDecl)schemaComponent).getName()) : null;
	} else {
		return schemaComponent instanceof XSAttributeUse && ((XSAttributeUse)schemaComponent).getFixedValue() != null ? fieldOutline.parent().parent().getModel().getNameConverter().toConstantName(((XSAttributeUse)schemaComponent).getDecl().getName()) : null;
	}
}
 
Example #29
Source File: CreateTypeInfoDelaration.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void appendEnumerationValues(final TypeInfoCompiler<T, C> typeInfoCompiler) {
	if (info instanceof MOriginated) {
		MOriginated<?> originated = (MOriginated<?>) info;
		Object origin = originated.getOrigin();
		if (origin instanceof SchemaComponentAware) {
			final XSComponent component = ((SchemaComponentAware) origin).getSchemaComponent();
			if (component != null) {

				final CollectEnumerationValuesVisitor collectEnumerationValuesVisitor = new CollectEnumerationValuesVisitor();
				component.visit(collectEnumerationValuesVisitor);
				final List<XmlString> enumerationValues = collectEnumerationValuesVisitor.getValues();
				if (enumerationValues != null && !enumerationValues.isEmpty()) {
					final JSArrayLiteral values = mappingCompiler.getCodeModel().array();
					boolean valueSupported = true;
					for (XmlString enumerationValue : enumerationValues) {
						final JSAssignmentExpression value = typeInfoCompiler.createValue(this.mappingCompiler,
								enumerationValue);
						if (value == null) {
							valueSupported = false;
							break;
						} else {
							values.append(value);
						}
					}
					if (valueSupported) {
						options.append(mappingCompiler.getNaming().values(), values);
					}
				}
			}
		}
	}
}
 
Example #30
Source File: CreateTypeInfoSchema.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public JsonSchemaBuilder visitBuiltinLeafInfo(MBuiltinLeafInfo<T, C> typeInfo) {
	final TypeInfoProducer<T, C> typeInfoCompiler = mappingCompiler.getTypeInfoProducer(info, typeInfo);
	final JsonSchemaBuilder typeInfoSchemaRef = typeInfoCompiler.createTypeInfoSchemaRef(mappingCompiler);

	if (info instanceof MOriginated) {
		MOriginated<?> originated = (MOriginated<?>) info;
		Object origin = originated.getOrigin();
		if (origin instanceof SchemaComponentAware) {
			final XSComponent component = ((SchemaComponentAware) origin).getSchemaComponent();
			if (component != null) {

				final CollectEnumerationValuesVisitor collectEnumerationValuesVisitor = new CollectEnumerationValuesVisitor();
				component.visit(collectEnumerationValuesVisitor);
				final List<XmlString> enumerationValues = collectEnumerationValuesVisitor.getValues();
				if (enumerationValues != null && !enumerationValues.isEmpty()) {
					final JsonSchemaBuilder values = new JsonSchemaBuilder();
					boolean valueSupported = true;
					for (XmlString enumerationValue : enumerationValues) {
						final JsonValue value = typeInfoCompiler.createValue(this.mappingCompiler,
								enumerationValue);
						if (value == null) {
							valueSupported = false;
							break;
						} else {
							values.addEnum(value);
						}
					}
					if (valueSupported) {
						final JsonSchemaBuilder typeInfoSchemaRefWithEnums = new JsonSchemaBuilder();
						typeInfoSchemaRefWithEnums.addAllOf(typeInfoSchemaRef);
						typeInfoSchemaRefWithEnums.addAllOf(values);
						return typeInfoSchemaRefWithEnums;
					}
				}
			}
		}
	}
	return typeInfoSchemaRef;
}