Java源码示例:com.sun.xml.internal.xsom.XSFacet
示例1
public XSFacet getDeclaredFacet( String name ) {
int len = facets.size();
for( int i=0; i<len; i++ ) {
XSFacet f = facets.get(i);
if(f.getName().equals(name))
return f;
}
return null;
}
示例2
public XSFacet getDeclaredFacet( String name ) {
int len = facets.size();
for( int i=0; i<len; i++ ) {
XSFacet f = facets.get(i);
if(f.getName().equals(name))
return f;
}
return null;
}
示例3
public Iterator<XSFacet> simpleType(XSSimpleType type) {
// TODO: it's not clear if "facets" mean all inherited facets or just declared facets
XSRestrictionSimpleType r = type.asRestriction();
if(r!=null)
return r.iterateDeclaredFacets();
else
return empty();
}
示例4
public void restrictionSimpleType( XSRestrictionSimpleType type ) {
if(type.getBaseType()==null) {
// don't print anySimpleType
if(!type.getName().equals("anySimpleType"))
throw new InternalError();
if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
throw new InternalError();
return;
}
XSSimpleType baseType = type.getSimpleBaseType();
println(MessageFormat.format("<restriction{0}>",
baseType.isLocal()?"":" base=\"{"+
baseType.getTargetNamespace()+'}'+
baseType.getName()+'\"'));
indent++;
if(baseType.isLocal())
simpleType(baseType);
Iterator itr = type.iterateDeclaredFacets();
while(itr.hasNext())
facet( (XSFacet)itr.next() );
indent--;
println("</restriction>");
}
示例5
public Iterator<XSFacet> simpleType(XSSimpleType type) {
// TODO: it's not clear if "facets" mean all inherited facets or just declared facets
XSRestrictionSimpleType r = type.asRestriction();
if(r!=null)
return r.iterateDeclaredFacets();
else
return empty();
}
示例6
public List<XSFacet> getFacets( String name ) {
List<XSFacet> f = getDeclaredFacets(name);
if(!f.isEmpty()) return f;
// none was found on this datatype. check the base type.
return getSimpleBaseType().getFacets(name);
}
示例7
public List<XSFacet> getFacets( String name ) {
List<XSFacet> f = getDeclaredFacets(name);
if(!f.isEmpty()) return f;
// none was found on this datatype. check the base type.
return getSimpleBaseType().getFacets(name);
}
示例8
private BigInteger readFacet(String facetName,int offset) {
XSFacet me = initiatingType.getFacet(facetName);
if(me==null)
return null;
BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
if(offset!=0)
bi = bi.add(BigInteger.valueOf(offset));
return bi;
}
示例9
public Iterator<XSFacet> simpleType(XSSimpleType type) {
// TODO: it's not clear if "facets" mean all inherited facets or just declared facets
XSRestrictionSimpleType r = type.asRestriction();
if(r!=null)
return r.iterateDeclaredFacets();
else
return empty();
}
示例10
private BigInteger readFacet(String facetName,int offset) {
XSFacet me = initiatingType.getFacet(facetName);
if(me==null)
return null;
BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
if(offset!=0)
bi = bi.add(BigInteger.valueOf(offset));
return bi;
}
示例11
public Iterator<XSFacet> simpleType(XSSimpleType type) {
// TODO: it's not clear if "facets" mean all inherited facets or just declared facets
XSRestrictionSimpleType r = type.asRestriction();
if(r!=null)
return r.iterateDeclaredFacets();
else
return empty();
}
示例12
public void restrictionSimpleType(XSRestrictionSimpleType type) {
if (type.getBaseType() == null) {
// don't print anySimpleType
if (!type.getName().equals("anySimpleType")) {
throw new InternalError();
}
if (!Const.schemaNamespace.equals(type.getTargetNamespace())) {
throw new InternalError();
}
return;
}
XSSimpleType baseType = type.getSimpleBaseType();
String str = MessageFormat.format("Restriction {0}",
new Object[]{baseType.isLocal() ? "" : " base=\"{"
+ baseType.getTargetNamespace() + "}"
+ baseType.getName() + "\""});
SchemaTreeNode newNode = new SchemaTreeNode(str, baseType.getLocator());
this.currNode.add(newNode);
this.currNode = newNode;
if (baseType.isLocal()) {
simpleType(baseType);
}
Iterator itr = type.iterateDeclaredFacets();
while (itr.hasNext()) {
facet((XSFacet) itr.next());
}
this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
示例13
private BigInteger readFacet(String facetName,int offset) {
XSFacet me = initiatingType.getFacet(facetName);
if(me==null)
return null;
BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
if(offset!=0)
bi = bi.add(BigInteger.valueOf(offset));
return bi;
}
示例14
public List<XSFacet> getFacets( String name ) {
List<XSFacet> f = getDeclaredFacets(name);
if(!f.isEmpty()) return f;
// none was found on this datatype. check the base type.
return getSimpleBaseType().getFacets(name);
}
示例15
public Iterator<XSFacet> simpleType(XSSimpleType type) {
// TODO: it's not clear if "facets" mean all inherited facets or just declared facets
XSRestrictionSimpleType r = type.asRestriction();
if(r!=null)
return r.iterateDeclaredFacets();
else
return empty();
}
示例16
public void restrictionSimpleType( XSRestrictionSimpleType type ) {
if(type.getBaseType()==null) {
// don't print anySimpleType
if(!type.getName().equals("anySimpleType"))
throw new InternalError();
if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
throw new InternalError();
return;
}
XSSimpleType baseType = type.getSimpleBaseType();
println(MessageFormat.format("<restriction{0}>",
baseType.isLocal()?"":" base=\"{"+
baseType.getTargetNamespace()+'}'+
baseType.getName()+'\"'));
indent++;
if(baseType.isLocal())
simpleType(baseType);
Iterator itr = type.iterateDeclaredFacets();
while(itr.hasNext())
facet( (XSFacet)itr.next() );
indent--;
println("</restriction>");
}
示例17
private BigInteger readFacet(String facetName,int offset) {
XSFacet me = initiatingType.getFacet(facetName);
if(me==null)
return null;
BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
if(offset!=0)
bi = bi.add(BigInteger.valueOf(offset));
return bi;
}
示例18
public XSFacet getDeclaredFacet( String name ) {
int len = facets.size();
for( int i=0; i<len; i++ ) {
XSFacet f = facets.get(i);
if(f.getName().equals(name))
return f;
}
return null;
}
示例19
private BigInteger readFacet(String facetName,int offset) {
XSFacet me = initiatingType.getFacet(facetName);
if(me==null)
return null;
BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
if(offset!=0)
bi = bi.add(BigInteger.valueOf(offset));
return bi;
}
示例20
private BigInteger readFacet(String facetName,int offset) {
XSFacet me = initiatingType.getFacet(facetName);
if(me==null)
return null;
BigInteger bi = DatatypeConverter.parseInteger(me.getValue().value);
if(offset!=0)
bi = bi.add(BigInteger.valueOf(offset));
return bi;
}
示例21
public XSFacet getDeclaredFacet( String name ) {
int len = facets.size();
for( int i=0; i<len; i++ ) {
XSFacet f = facets.get(i);
if(f.getName().equals(name))
return f;
}
return null;
}
示例22
public List<XSFacet> getDeclaredFacets(String name) {
List<XSFacet> r = new ArrayList<XSFacet>();
for( XSFacet f : facets )
if(f.getName().equals(name))
r.add(f);
return r;
}
示例23
public XSFacet getFacet( String name ) {
XSFacet f = getDeclaredFacet(name);
if(f!=null) return f;
// none was found on this datatype. check the base type.
return getSimpleBaseType().getFacet(name);
}
示例24
public void restrictionSimpleType( XSRestrictionSimpleType type ) {
if(type.getBaseType()==null) {
// don't print anySimpleType
if(!type.getName().equals("anySimpleType"))
throw new InternalError();
if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
throw new InternalError();
return;
}
XSSimpleType baseType = type.getSimpleBaseType();
println(MessageFormat.format("<restriction{0}>",
baseType.isLocal()?"":" base=\"{"+
baseType.getTargetNamespace()+'}'+
baseType.getName()+'\"'));
indent++;
if(baseType.isLocal())
simpleType(baseType);
Iterator itr = type.iterateDeclaredFacets();
while(itr.hasNext())
facet( (XSFacet)itr.next() );
indent--;
println("</restriction>");
}
示例25
public void addFacet( XSFacet facet ) {
facets.add(facet);
}
示例26
public Iterator<XSFacet> iterateDeclaredFacets() {
return facets.iterator();
}
示例27
public CElement facet(XSFacet xsFacet) {
return core.facet(xsFacet);
}
示例28
protected boolean match(XSFacet f) {
return f.getName().equals(name);
}
示例29
protected boolean match(XSFacet f) {
return f.getName().equals(name);
}
示例30
/**
* Returns true if a type-safe enum should be created from
* the given simple type by default without an explicit <jaxb:enum> customization.
*/
private boolean shouldBeMappedToTypeSafeEnumByDefault( XSRestrictionSimpleType type ) {
// if not, there will be a problem wrt the class name of this type safe enum type.
if( type.isLocal() ) return false;
// if redefined, we should map the new definition, not the old one.
if( type.getRedefinedBy()!=null ) return false;
List<XSFacet> facets = type.getDeclaredFacets(XSFacet.FACET_ENUMERATION);
if( facets.isEmpty() )
// if the type itself doesn't have the enumeration facet,
// it won't be mapped to a type-safe enum.
return false;
if(facets.size() > builder.getGlobalBinding().getDefaultEnumMemberSizeCap()) {
// if there are too many facets, it's not very useful
// produce warning when simple type is not mapped to enum
// see issue https://jaxb.dev.java.net/issues/show_bug.cgi?id=711
if(reportedEnumMemberSizeWarnings == null)
reportedEnumMemberSizeWarnings = new HashSet<XSRestrictionSimpleType>();
if(!reportedEnumMemberSizeWarnings.contains(type)) {
getErrorReporter().warning(type.getLocator(), Messages.WARN_ENUM_MEMBER_SIZE_CAP,
type.getName(), facets.size(), builder.getGlobalBinding().getDefaultEnumMemberSizeCap());
reportedEnumMemberSizeWarnings.add(type);
}
return false;
}
if( !canBeMappedToTypeSafeEnum(type) )
// we simply can't map this to an enumeration
return false;
// check for collisions among constant names. if a collision will happen,
// don't try to bind it to an enum.
// return true only when this type is derived from one of the "enum base type".
for( XSSimpleType t = type; t!=null; t=t.getSimpleBaseType() )
if( t.isGlobal() && builder.getGlobalBinding().canBeMappedToTypeSafeEnum(t) )
return true;
return false;
}