本文整理汇总了Java中org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction类的典型用法代码示例。如果您正苦于以下问题:Java XmlSchemaSimpleTypeRestriction类的具体用法?Java XmlSchemaSimpleTypeRestriction怎么用?Java XmlSchemaSimpleTypeRestriction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlSchemaSimpleTypeRestriction类属于org.apache.ws.commons.schema包,在下文中一共展示了XmlSchemaSimpleTypeRestriction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: walkSimpleTypeRestriction
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
protected void walkSimpleTypeRestriction(XmlSchema xmlSchema, XmlSchemaSimpleTypeRestriction obj) {
walkAnnotated(xmlSchema, obj);
QName qname = obj.getBaseTypeName();
if ((qname != null) && (deep)) {
walkByTypeName(xmlSchema, qname);
} else {
XmlSchemaSimpleType type = obj.getBaseType();
if (type != null) {
walkSimpleType(xmlSchema, type);
}
}
XmlSchemaObjectCollection facets = obj.getFacets();
for (int i = 0; i < facets.getCount(); i++) {
XmlSchemaFacet facet = (XmlSchemaFacet) facets.getItem(i);
walkFacet(xmlSchema, facet);
}
}
示例2: createAlphaXmlSchemaSimpleType
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
/**
* Create a simple type for an alphanumeric type.
* <p>
* COBOL alphanumeric fields are fixed length so we create a facet to
* enforce that constraint. A pattern derived from the picture clause can
* also be used as a facet. If the item has children conditions, we add
* enumeration facets
*
* @param xsdDataItem COBOL data item decorated with XSD attributes
* @param xsdTypeName the XML schema built-in type name to use as a
* restriction
* @return an XML schema simple type
*/
protected XmlSchemaSimpleType createAlphaXmlSchemaSimpleType(
final XsdDataItem xsdDataItem, final String xsdTypeName) {
XmlSchemaSimpleTypeRestriction restriction = createRestriction(xsdTypeName);
if (xsdDataItem.getLength() > -1) {
restriction.getFacets().add(
createMaxLengthFacet(xsdDataItem.getLength()));
}
if (xsdDataItem.getPattern() != null) {
restriction.getFacets().add(
createPatternFacet(xsdDataItem.getPattern()));
}
addEnumerationFacets(xsdDataItem, restriction);
return createXmlSchemaSimpleType(restriction);
}
示例3: createAlphaXmlSchemaSimpleType
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
/**
* Create a simple type for an alphanumeric type.
* <p/>
* COBOL alphanumeric fields are fixed length so we create a facet to
* enforce that constraint. A pattern derived from the picture clause can
* also be used as a facet. If the item has children conditions, we add
* enumeration facets
*
* @param xsdDataItem COBOL data item decorated with XSD attributes
* @param xsdTypeName the XML schema built-in type name to use as a
* restriction
* @return an XML schema simple type
*/
protected XmlSchemaSimpleType createAlphaXmlSchemaSimpleType(
final XsdDataItem xsdDataItem, final String xsdTypeName) {
XmlSchemaSimpleTypeRestriction restriction = createRestriction(xsdTypeName);
if (xsdDataItem.getLength() > -1) {
restriction.getFacets().add(
createMaxLengthFacet(xsdDataItem.getLength()));
}
if (xsdDataItem.getPattern() != null) {
restriction.getFacets().add(
createPatternFacet(xsdDataItem.getPattern()));
}
addEnumerationFacets(xsdDataItem, restriction);
return createXmlSchemaSimpleType(restriction);
}
示例4: getSimpleTypeName
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
private static final QName getSimpleTypeName(final XmlSchemaSimpleType simpleType) {
final QName typeName = simpleType.getQName();
if (null == typeName) {
// The type is anonymous.
final XmlSchemaSimpleTypeContent content = simpleType.getContent();
if (content instanceof XmlSchemaSimpleTypeRestriction) {
final XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
return restriction.getBaseTypeName();
} else if (content instanceof XmlSchemaSimpleTypeList) {
final XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList) content;
return list.getItemTypeName();
} else {
throw new AssertionError(content);
}
} else {
return typeName;
}
}
示例5: walkSimpleType
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
protected void walkSimpleType(XmlSchema xmlSchema, XmlSchemaSimpleType obj) {
walkAnnotated(xmlSchema, obj);
XmlSchemaSimpleTypeContent simpleTypeContent = obj.getContent();
if (simpleTypeContent != null) {
if (simpleTypeContent instanceof XmlSchemaSimpleTypeRestriction) {
walkSimpleTypeRestriction(xmlSchema, (XmlSchemaSimpleTypeRestriction)simpleTypeContent);
} else if (simpleTypeContent instanceof XmlSchemaSimpleTypeList) {
walkSimpleTypeList(xmlSchema, (XmlSchemaSimpleTypeList)simpleTypeContent);
} else if (simpleTypeContent instanceof XmlSchemaSimpleTypeUnion) {
walkSimpleTypeUnion(xmlSchema, (XmlSchemaSimpleTypeUnion)simpleTypeContent);
}
}
}
示例6: createXmlSchemaSimpleType
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
/**
* Create an XML schema simple type from a restriction.
*
* @param restriction the XML schema restriction
* @return the XML schema simple type
*/
protected XmlSchemaSimpleType createXmlSchemaSimpleType(
final XmlSchemaSimpleTypeRestriction restriction) {
XmlSchemaSimpleType xmlSchemaSimpleType = new XmlSchemaSimpleType(
getXsd());
xmlSchemaSimpleType.setContent(restriction);
return xmlSchemaSimpleType;
}
示例7: createRestriction
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
/**
* Create an XML schema restriction.
*
* @param xsdTypeName the XML schema built-in type name to use as a
* restriction
* @return an XML schema restriction
*/
protected XmlSchemaSimpleTypeRestriction createRestriction(
final String xsdTypeName) {
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
restriction.setBaseTypeName(new QName(
XMLConstants.W3C_XML_SCHEMA_NS_URI, xsdTypeName));
return restriction;
}
示例8: createXmlSchemaSimpleType
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
/**
* Create an XML schema simple type from a restriction.
*
* @param restriction the XML schema restriction
* @return the XML schema simple type
*/
protected XmlSchemaSimpleType createXmlSchemaSimpleType(
final XmlSchemaSimpleTypeRestriction restriction) {
XmlSchemaSimpleType xmlSchemaSimpleType = new XmlSchemaSimpleType(
getXsd(), false);
xmlSchemaSimpleType.setContent(restriction);
return xmlSchemaSimpleType;
}
示例9: writeSchema
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
@Override
public void writeSchema(XmlSchema root) {
if (serializedWhenUnknown) {
XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root, true);
simple.setName("serializedJavaObject");
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
simple.setContent(restriction);
restriction.setBaseTypeName(XmlSchemaConstants.BASE64BINARY_QNAME);
}
}
示例10: getSimpleContentTypeName
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
private QName getSimpleContentTypeName(XmlSchemaSimpleType schemaSimpleType) {
QName simpleContentTypeName = null;
if (schemaSimpleType.getContent() != null
&& schemaSimpleType.getContent() instanceof XmlSchemaSimpleTypeRestriction) {
XmlSchemaSimpleTypeRestriction simpleContent = (XmlSchemaSimpleTypeRestriction) schemaSimpleType
.getContent();
simpleContentTypeName = simpleContent.getBaseTypeName();
} else {
throw new RuntimeException("Unsupported simple content model: "
+ schemaSimpleType.getContent().getClass().getCanonicalName());
}
return simpleContentTypeName;
}
示例11: decorateText
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
public String decorateText(String text, Object element) {
String decoratedText = text;
if (element != null) {
if (element instanceof XmlSchemaObject) {
XmlSchemaObject xso = (XmlSchemaObject) element;
XmlSchemaType type = null;
String value = null;
if (element instanceof XmlSchemaElement) {
type = SchemaMeta.getType(xso, ((XmlSchemaElement) element).getSchemaTypeName());
} else if (element instanceof XmlSchemaAttribute) {
XmlSchemaAttribute attr = (XmlSchemaAttribute) element;
type = SchemaMeta.getType(xso, attr.getSchemaTypeName());
value = attr.getDefaultValue();
value = value == null ? attr.getFixedValue() : "default:" + value;
} else if (element instanceof XmlSchemaSimpleContentExtension) {
type = SchemaMeta.getType(xso, ((XmlSchemaSimpleContentExtension) element).getBaseTypeName());
} else if (element instanceof XmlSchemaSimpleTypeRestriction) {
type = SchemaMeta.getType(xso, ((XmlSchemaSimpleTypeRestriction) element).getBaseTypeName());
} else if (element instanceof XmlSchemaEnumerationFacet) {
XmlSchemaEnumerationFacet enumerationFacet = (XmlSchemaEnumerationFacet) element;
decoratedText += " [" + enumerationFacet.getValue() + "]";
}
if (value != null) {
decoratedText += " {" + value + "}";
}
if (type != null && type instanceof XmlSchemaSimpleType) {
decoratedText += " [" + SchemaMeta.getPrefix(type) + ":" + type.getName() + "]";
}
int size = SchemaMeta.getReferencedDatabaseObjects(xso).size();
if (size > 1 || size >= 0 && element instanceof XmlSchemaComplexType && ((XmlSchemaComplexType) element).getName() != null) {
decoratedText += " (" + size + ")";
}
String prefix = SchemaMeta.getPrefix(xso);
if (prefix != null) {
decoratedText = prefix + ":" + decoratedText;
}
}
}
return decoratedText;
}
示例12: walk
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
protected void walk(XmlSchema xmlSchema, XmlSchemaObject obj) {
if (obj instanceof XmlSchema) {
walk((XmlSchema) obj);
} else if (obj instanceof XmlSchemaElement) {
walkElement(xmlSchema, (XmlSchemaElement) obj);
} else if (obj instanceof XmlSchemaSimpleType) {
walkSimpleType(xmlSchema, (XmlSchemaSimpleType) obj);
} else if (obj instanceof XmlSchemaSimpleTypeRestriction) {
walkSimpleTypeRestriction(xmlSchema, (XmlSchemaSimpleTypeRestriction) obj);
} else if (obj instanceof XmlSchemaSimpleTypeList) {
walkSimpleTypeList(xmlSchema, (XmlSchemaSimpleTypeList) obj);
} else if (obj instanceof XmlSchemaSimpleTypeUnion) {
walkSimpleTypeUnion(xmlSchema, (XmlSchemaSimpleTypeUnion) obj);
} else if (obj instanceof XmlSchemaComplexType) {
walkComplexType(xmlSchema, (XmlSchemaComplexType) obj);
} else if (obj instanceof XmlSchemaGroupRef) {
walkGroupRef(xmlSchema, (XmlSchemaGroupRef) obj);
} else if (obj instanceof XmlSchemaIdentityConstraint) {
walkIdentityConstraint(xmlSchema, (XmlSchemaIdentityConstraint) obj);
} else if (obj instanceof XmlSchemaImport) {
walkImport(xmlSchema, (XmlSchemaImport) obj);
} else if (obj instanceof XmlSchemaInclude) {
walkInclude(xmlSchema, (XmlSchemaInclude) obj);
} else if (obj instanceof XmlSchemaAll) {
walkAll(xmlSchema, (XmlSchemaAll) obj);
} else if (obj instanceof XmlSchemaAnnotation) {
walkAnnotation(xmlSchema, (XmlSchemaAnnotation) obj);
} else if (obj instanceof XmlSchemaDocumentation) {
walkDocumentation(xmlSchema, (XmlSchemaDocumentation) obj);
} else if (obj instanceof XmlSchemaAppInfo) {
walkAppInfo(xmlSchema, (XmlSchemaAppInfo) obj);
} else if (obj instanceof XmlSchemaChoice) {
walkChoice(xmlSchema, (XmlSchemaChoice) obj);
} else if (obj instanceof XmlSchemaSequence) {
walkSequence(xmlSchema, (XmlSchemaSequence) obj);
} else if (obj instanceof XmlSchemaAny) {
walkAny(xmlSchema, (XmlSchemaAny) obj);
} else if (obj instanceof XmlSchemaSimpleContent) {
walkSimpleContent(xmlSchema, (XmlSchemaSimpleContent) obj);
} else if (obj instanceof XmlSchemaSimpleContentRestriction) {
walkSimpleContentRestriction(xmlSchema, (XmlSchemaSimpleContentRestriction) obj);
} else if (obj instanceof XmlSchemaFacet) {
walkFacet(xmlSchema, (XmlSchemaFacet) obj);
} else if (obj instanceof XmlSchemaXPath) {
walkField(xmlSchema, (XmlSchemaXPath) obj);
} else if (obj instanceof XmlSchemaAttributeGroupRef) {
walkAttributeGroupRef(xmlSchema, (XmlSchemaAttributeGroupRef) obj);
} else if (obj instanceof XmlSchemaSimpleContentExtension) {
walkSimpleContentExtension(xmlSchema, (XmlSchemaSimpleContentExtension) obj);
} else if (obj instanceof XmlSchemaAnyAttribute) {
walkAnyAttribute(xmlSchema, (XmlSchemaAnyAttribute) obj);
} else if (obj instanceof XmlSchemaComplexContent) {
walkComplexContent(xmlSchema, (XmlSchemaComplexContent) obj);
} else if (obj instanceof XmlSchemaComplexContentExtension) {
walkComplexContentExtension(xmlSchema, (XmlSchemaComplexContentExtension) obj);
} else if (obj instanceof XmlSchemaComplexContentRestriction) {
walkComplexContentRestriction(xmlSchema, (XmlSchemaComplexContentRestriction) obj);
} else if (obj instanceof XmlSchemaGroup) {
walkGroup(xmlSchema, (XmlSchemaGroup) obj);
} else if (obj instanceof XmlSchemaAttributeGroup) {
walkAttributeGroup(xmlSchema, (XmlSchemaAttributeGroup) obj);
} else if (obj instanceof XmlSchemaAttribute) {
walkAttribute(xmlSchema, (XmlSchemaAttribute) obj);
} else if (obj instanceof XmlSchemaRedefine) {
walkRedefine(xmlSchema, (XmlSchemaRedefine) obj);
}
}
示例13: createNumericXmlSchemaSimpleType
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
/**
* Create a simple type for an numeric type.
* <p>
* Numeric elements might have totaDigits, fractionDigits, minInclusive or
* maxInclusive facets.
*
* @param xsdDataItem COBOL data item decorated with XSD attributes
* @param xsdTypeName the XML schema built-in type name to use as a
* restriction
* @return an XML schema simple type
*/
protected XmlSchemaSimpleType createNumericXmlSchemaSimpleType(
final XsdDataItem xsdDataItem, final String xsdTypeName) {
XmlSchemaSimpleTypeRestriction restriction = createRestriction(xsdTypeName);
/*
* COBOL native binary are special because even though they have a
* totalDigits attribute, it is not used enforce a restriction.
*/
if (xsdDataItem.getCobolType() != CobolType.NATIVE_BINARY_ITEM
&& xsdDataItem.getTotalDigits() > -1) {
/*
* Due to a bug in JAXB (see JAXB issue 715), unsignedLong may end
* up being mapped to BigInteger instead of Long when totalDigits is
* used instead of maxInclusive. So for now, we keep maxInclusive.
*/
if (xsdDataItem.getXsdType() == XsdType.ULONG) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < xsdDataItem.getTotalDigits(); i++) {
sb.append("9");
}
restriction.getFacets().add(
createMaxInclusiveFacet(sb.toString()));
} else {
restriction.getFacets().add(
createTotalDigitsFacet(xsdDataItem.getTotalDigits()));
}
}
/* fractionDigits is a fixed facet for most numerics so be careful */
if (xsdDataItem.getFractionDigits() > 0) {
restriction.getFacets().add(
createFractionDigitsFacet(xsdDataItem.getFractionDigits()));
}
/*
* For xsd:decimal and xsd:integer, we further constrain if the numeric
* needs to be positive (unsigned).
*/
if ((xsdDataItem.getXsdType() == XsdType.INTEGER || xsdDataItem
.getXsdType() == XsdType.DECIMAL) && !xsdDataItem.isSigned()) {
restriction.getFacets().add(createMinInclusiveFacet("0"));
}
addEnumerationFacets(xsdDataItem, restriction);
return createXmlSchemaSimpleType(restriction);
}
示例14: addEnumerationFacets
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
/**
* If simple type has conditions attached to it, emit enumeration facets.
*
* @param xsdDataItem COBOL data item decorated with XSD attributes
* @param restriction the current set of constraints
*/
protected void addEnumerationFacets(final XsdDataItem xsdDataItem,
final XmlSchemaSimpleTypeRestriction restriction) {
if (getModel().mapConditionsToFacets()) {
boolean hasValueThru = false;
for (XsdDataItem child : xsdDataItem.getChildren()) {
if (child.getDataEntryType() == DataEntryType.CONDITION) {
for (String conditionValue : child.getConditionLiterals()) {
restriction.getFacets().add(
createEnumerationFacet(ValueUtil
.resolveFigurative(conditionValue,
xsdDataItem
.getMaxStorageLength(),
getModel().quoteIsQuote())));
}
for (Range conditionRange : child.getConditionRanges()) {
if (hasValueThru) {
_log.warn(xsdDataItem.getCobolName()
+ " has several VALUE THRU statements."
+ " Cannot translate to XSD."
+ " Only the first one will be converted."
+ " Ignoring: " + conditionRange.toString());
break;
}
restriction.getFacets().add(
createMinInclusiveFacet(ValueUtil
.resolveFigurative(conditionRange
.getFrom(), xsdDataItem
.getMaxStorageLength(),
getModel().quoteIsQuote())));
restriction.getFacets().add(
createMaxInclusiveFacet(ValueUtil
.resolveFigurative(conditionRange
.getTo(), xsdDataItem
.getMaxStorageLength(),
getModel().quoteIsQuote())));
hasValueThru = true;
}
}
}
}
}
示例15: createNumericXmlSchemaSimpleType
import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction; //导入依赖的package包/类
/**
* Create a simple type for an numeric type.
* <p/>
* Numeric elements might have totaDigits, fractionDigits, minInclusive or
* maxInclusive facets.
*
* @param xsdDataItem COBOL data item decorated with XSD attributes
* @param xsdTypeName the XML schema built-in type name to use as a
* restriction
* @return an XML schema simple type
*/
protected XmlSchemaSimpleType createNumericXmlSchemaSimpleType(
final XsdDataItem xsdDataItem, final String xsdTypeName) {
XmlSchemaSimpleTypeRestriction restriction = createRestriction(xsdTypeName);
/*
* COBOL native binary are special because even though they have a
* totalDigits attribute, it is not used enforce a restriction.
*/
if (xsdDataItem.getCobolType() != CobolTypes.NATIVE_BINARY_ITEM
&& xsdDataItem.getTotalDigits() > -1) {
/*
* Due to a bug in JAXB (see JAXB issue 715), unsignedLong may end
* up being mapped to BigInteger instead of Long when totalDigits is
* used instead of maxInclusive. So for now, we keep maxInclusive.
*/
if (xsdDataItem.getXsdType() == XsdType.ULONG) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < xsdDataItem.getTotalDigits(); i++) {
sb.append("9");
}
restriction.getFacets().add(
createMaxInclusiveFacet(sb.toString()));
} else {
restriction.getFacets().add(
createTotalDigitsFacet(xsdDataItem.getTotalDigits()));
}
}
/* fractionDigits is a fixed facet for most numerics so be careful */
if (xsdDataItem.getFractionDigits() > 0) {
restriction.getFacets().add(
createFractionDigitsFacet(xsdDataItem.getFractionDigits()));
}
/*
* For xsd:decimal and xsd:integer, we further constrain if the numeric
* needs to be positive (unsigned).
*/
if ((xsdDataItem.getXsdType() == XsdType.INTEGER || xsdDataItem
.getXsdType() == XsdType.DECIMAL) && !xsdDataItem.isSigned()) {
restriction.getFacets().add(createMinInclusiveFacet("0"));
}
addEnumerationFacets(xsdDataItem, restriction);
return createXmlSchemaSimpleType(restriction);
}