Java Code Examples for com.sun.codemodel.internal.JJavaName#isJavaIdentifier()
The following examples show how to use
com.sun.codemodel.internal.JJavaName#isJavaIdentifier() .
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: CPropertyInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example 2
Source File: CPropertyInfo.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example 3
Source File: CPropertyInfo.java From hottub with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example 4
Source File: CPropertyInfo.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example 5
Source File: CPropertyInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example 6
Source File: CPropertyInfo.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example 7
Source File: CPropertyInfo.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example 8
Source File: CodeModelClassFactory.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public JDefinedClass createClass( JClassContainer parent, int mod, String name, Locator source, ClassType kind ) { if(!JJavaName.isJavaIdentifier(name)) { // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_INVALID_CLASSNAME, name ), source )); return createDummyClass(parent); } try { if(parent.isClass() && kind==ClassType.CLASS) mod |= JMod.STATIC; JDefinedClass r = parent._class(mod,name,kind); // use the metadata field to store the source location, // so that we can report class name collision errors. r.metadata = source; return r; } catch( JClassAlreadyExistsException e ) { // class collision. JDefinedClass cls = e.getExistingClass(); // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION, cls.fullName() ), (Locator)cls.metadata )); errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION_SOURCE, name ), source )); if( !name.equals(cls.name()) ) { // on Windows, FooBar and Foobar causes name collision errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CASE_SENSITIVITY_COLLISION, name, cls.name() ), null ) ); } if(Util.equals((Locator)cls.metadata,source)) { errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CHAMELEON_SCHEMA_GONE_WILD ), source )); } return createDummyClass(parent); } }
Example 9
Source File: SimpleTypeBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * * @param errorRef * if constant names couldn't be generated, return a reference to that enum facet. * @return * null if unable to generate names for some of the constants. */ private List<CEnumConstant> buildCEnumConstants(XSRestrictionSimpleType type, boolean needsToGenerateMemberName, Map<String, BIEnumMember> members, XSFacet[] errorRef) { List<CEnumConstant> memberList = new ArrayList<CEnumConstant>(); int idx=1; Set<String> enums = new HashSet<String>(); // to avoid duplicates. See issue #366 for( XSFacet facet : type.getDeclaredFacets(XSFacet.FACET_ENUMERATION)) { String name=null; String mdoc=builder.getBindInfo(facet).getDocumentation(); if(!enums.add(facet.getValue().value)) continue; // ignore the 2nd occasion if( needsToGenerateMemberName ) { // generate names for all member names. // this will even override names specified by the user. that's crazy. name = "VALUE_"+(idx++); } else { String facetValue = facet.getValue().value; BIEnumMember mem = members.get(facetValue); if( mem==null ) // look at the one attached to the facet object mem = builder.getBindInfo(facet).get(BIEnumMember.class); if (mem!=null) { name = mem.name; if (mdoc == null) { mdoc = mem.javadoc; } } if(name==null) { StringBuilder sb = new StringBuilder(); for( int i=0; i<facetValue.length(); i++) { char ch = facetValue.charAt(i); if(Character.isJavaIdentifierPart(ch)) sb.append(ch); else sb.append('_'); } name = model.getNameConverter().toConstantName(sb.toString()); } } if(!JJavaName.isJavaIdentifier(name)) { if(errorRef!=null) errorRef[0] = facet; return null; // unable to generate a name } memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator())); } return memberList; }
Example 10
Source File: CodeModelClassFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public JDefinedClass createClass( JClassContainer parent, int mod, String name, Locator source, ClassType kind ) { if(!JJavaName.isJavaIdentifier(name)) { // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_INVALID_CLASSNAME, name ), source )); return createDummyClass(parent); } try { if(parent.isClass() && kind==ClassType.CLASS) mod |= JMod.STATIC; JDefinedClass r = parent._class(mod,name,kind); // use the metadata field to store the source location, // so that we can report class name collision errors. r.metadata = source; return r; } catch( JClassAlreadyExistsException e ) { // class collision. JDefinedClass cls = e.getExistingClass(); // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION, cls.fullName() ), (Locator)cls.metadata )); errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION_SOURCE, name ), source )); if( !name.equals(cls.name()) ) { // on Windows, FooBar and Foobar causes name collision errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CASE_SENSITIVITY_COLLISION, name, cls.name() ), null ) ); } if(Util.equals((Locator)cls.metadata,source)) { errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CHAMELEON_SCHEMA_GONE_WILD ), source )); } return createDummyClass(parent); } }
Example 11
Source File: SimpleTypeBuilder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * * @param errorRef * if constant names couldn't be generated, return a reference to that enum facet. * @return * null if unable to generate names for some of the constants. */ private List<CEnumConstant> buildCEnumConstants(XSRestrictionSimpleType type, boolean needsToGenerateMemberName, Map<String, BIEnumMember> members, XSFacet[] errorRef) { List<CEnumConstant> memberList = new ArrayList<CEnumConstant>(); int idx=1; Set<String> enums = new HashSet<String>(); // to avoid duplicates. See issue #366 for( XSFacet facet : type.getDeclaredFacets(XSFacet.FACET_ENUMERATION)) { String name=null; String mdoc=builder.getBindInfo(facet).getDocumentation(); if(!enums.add(facet.getValue().value)) continue; // ignore the 2nd occasion if( needsToGenerateMemberName ) { // generate names for all member names. // this will even override names specified by the user. that's crazy. name = "VALUE_"+(idx++); } else { String facetValue = facet.getValue().value; BIEnumMember mem = members.get(facetValue); if( mem==null ) // look at the one attached to the facet object mem = builder.getBindInfo(facet).get(BIEnumMember.class); if (mem!=null) { name = mem.name; if (mdoc == null) { mdoc = mem.javadoc; } } if(name==null) { StringBuilder sb = new StringBuilder(); for( int i=0; i<facetValue.length(); i++) { char ch = facetValue.charAt(i); if(Character.isJavaIdentifierPart(ch)) sb.append(ch); else sb.append('_'); } name = model.getNameConverter().toConstantName(sb.toString()); } } if(!JJavaName.isJavaIdentifier(name)) { if(errorRef!=null) errorRef[0] = facet; return null; // unable to generate a name } memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator())); } return memberList; }
Example 12
Source File: SimpleTypeBuilder.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * * @param errorRef * if constant names couldn't be generated, return a reference to that enum facet. * @return * null if unable to generate names for some of the constants. */ private List<CEnumConstant> buildCEnumConstants(XSRestrictionSimpleType type, boolean needsToGenerateMemberName, Map<String, BIEnumMember> members, XSFacet[] errorRef) { List<CEnumConstant> memberList = new ArrayList<CEnumConstant>(); int idx=1; Set<String> enums = new HashSet<String>(); // to avoid duplicates. See issue #366 for( XSFacet facet : type.getDeclaredFacets(XSFacet.FACET_ENUMERATION)) { String name=null; String mdoc=builder.getBindInfo(facet).getDocumentation(); if(!enums.add(facet.getValue().value)) continue; // ignore the 2nd occasion if( needsToGenerateMemberName ) { // generate names for all member names. // this will even override names specified by the user. that's crazy. name = "VALUE_"+(idx++); } else { String facetValue = facet.getValue().value; BIEnumMember mem = members.get(facetValue); if( mem==null ) // look at the one attached to the facet object mem = builder.getBindInfo(facet).get(BIEnumMember.class); if (mem!=null) { name = mem.name; if (mdoc == null) { mdoc = mem.javadoc; } } if(name==null) { StringBuilder sb = new StringBuilder(); for( int i=0; i<facetValue.length(); i++) { char ch = facetValue.charAt(i); if(Character.isJavaIdentifierPart(ch)) sb.append(ch); else sb.append('_'); } name = model.getNameConverter().toConstantName(sb.toString()); } } if(!JJavaName.isJavaIdentifier(name)) { if(errorRef!=null) errorRef[0] = facet; return null; // unable to generate a name } memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator())); } return memberList; }
Example 13
Source File: CodeModelClassFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public JDefinedClass createClass( JClassContainer parent, int mod, String name, Locator source, ClassType kind ) { if(!JJavaName.isJavaIdentifier(name)) { // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_INVALID_CLASSNAME, name ), source )); return createDummyClass(parent); } try { if(parent.isClass() && kind==ClassType.CLASS) mod |= JMod.STATIC; JDefinedClass r = parent._class(mod,name,kind); // use the metadata field to store the source location, // so that we can report class name collision errors. r.metadata = source; return r; } catch( JClassAlreadyExistsException e ) { // class collision. JDefinedClass cls = e.getExistingClass(); // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION, cls.fullName() ), (Locator)cls.metadata )); errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION_SOURCE, name ), source )); if( !name.equals(cls.name()) ) { // on Windows, FooBar and Foobar causes name collision errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CASE_SENSITIVITY_COLLISION, name, cls.name() ), null ) ); } if(Util.equals((Locator)cls.metadata,source)) { errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CHAMELEON_SCHEMA_GONE_WILD ), source )); } return createDummyClass(parent); } }
Example 14
Source File: SimpleTypeBuilder.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * * @param errorRef * if constant names couldn't be generated, return a reference to that enum facet. * @return * null if unable to generate names for some of the constants. */ private List<CEnumConstant> buildCEnumConstants(XSRestrictionSimpleType type, boolean needsToGenerateMemberName, Map<String, BIEnumMember> members, XSFacet[] errorRef) { List<CEnumConstant> memberList = new ArrayList<CEnumConstant>(); int idx=1; Set<String> enums = new HashSet<String>(); // to avoid duplicates. See issue #366 for( XSFacet facet : type.getDeclaredFacets(XSFacet.FACET_ENUMERATION)) { String name=null; String mdoc=builder.getBindInfo(facet).getDocumentation(); if(!enums.add(facet.getValue().value)) continue; // ignore the 2nd occasion if( needsToGenerateMemberName ) { // generate names for all member names. // this will even override names specified by the user. that's crazy. name = "VALUE_"+(idx++); } else { String facetValue = facet.getValue().value; BIEnumMember mem = members.get(facetValue); if( mem==null ) // look at the one attached to the facet object mem = builder.getBindInfo(facet).get(BIEnumMember.class); if (mem!=null) { name = mem.name; if (mdoc == null) { mdoc = mem.javadoc; } } if(name==null) { StringBuilder sb = new StringBuilder(); for( int i=0; i<facetValue.length(); i++) { char ch = facetValue.charAt(i); if(Character.isJavaIdentifierPart(ch)) sb.append(ch); else sb.append('_'); } name = model.getNameConverter().toConstantName(sb.toString()); } } if(!JJavaName.isJavaIdentifier(name)) { if(errorRef!=null) errorRef[0] = facet; return null; // unable to generate a name } memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator())); } return memberList; }
Example 15
Source File: CodeModelClassFactory.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public JDefinedClass createClass( JClassContainer parent, int mod, String name, Locator source, ClassType kind ) { if(!JJavaName.isJavaIdentifier(name)) { // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_INVALID_CLASSNAME, name ), source )); return createDummyClass(parent); } try { if(parent.isClass() && kind==ClassType.CLASS) mod |= JMod.STATIC; JDefinedClass r = parent._class(mod,name,kind); // use the metadata field to store the source location, // so that we can report class name collision errors. r.metadata = source; return r; } catch( JClassAlreadyExistsException e ) { // class collision. JDefinedClass cls = e.getExistingClass(); // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION, cls.fullName() ), (Locator)cls.metadata )); errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION_SOURCE, name ), source )); if( !name.equals(cls.name()) ) { // on Windows, FooBar and Foobar causes name collision errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CASE_SENSITIVITY_COLLISION, name, cls.name() ), null ) ); } if(Util.equals((Locator)cls.metadata,source)) { errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CHAMELEON_SCHEMA_GONE_WILD ), source )); } return createDummyClass(parent); } }
Example 16
Source File: CodeModelClassFactory.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public JDefinedClass createClass( JClassContainer parent, int mod, String name, Locator source, ClassType kind ) { if(!JJavaName.isJavaIdentifier(name)) { // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_INVALID_CLASSNAME, name ), source )); return createDummyClass(parent); } try { if(parent.isClass() && kind==ClassType.CLASS) mod |= JMod.STATIC; JDefinedClass r = parent._class(mod,name,kind); // use the metadata field to store the source location, // so that we can report class name collision errors. r.metadata = source; return r; } catch( JClassAlreadyExistsException e ) { // class collision. JDefinedClass cls = e.getExistingClass(); // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION, cls.fullName() ), (Locator)cls.metadata )); errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION_SOURCE, name ), source )); if( !name.equals(cls.name()) ) { // on Windows, FooBar and Foobar causes name collision errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CASE_SENSITIVITY_COLLISION, name, cls.name() ), null ) ); } if(Util.equals((Locator)cls.metadata,source)) { errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CHAMELEON_SCHEMA_GONE_WILD ), source )); } return createDummyClass(parent); } }
Example 17
Source File: SimpleTypeBuilder.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * * @param errorRef * if constant names couldn't be generated, return a reference to that enum facet. * @return * null if unable to generate names for some of the constants. */ private List<CEnumConstant> buildCEnumConstants(XSRestrictionSimpleType type, boolean needsToGenerateMemberName, Map<String, BIEnumMember> members, XSFacet[] errorRef) { List<CEnumConstant> memberList = new ArrayList<CEnumConstant>(); int idx=1; Set<String> enums = new HashSet<String>(); // to avoid duplicates. See issue #366 for( XSFacet facet : type.getDeclaredFacets(XSFacet.FACET_ENUMERATION)) { String name=null; String mdoc=builder.getBindInfo(facet).getDocumentation(); if(!enums.add(facet.getValue().value)) continue; // ignore the 2nd occasion if( needsToGenerateMemberName ) { // generate names for all member names. // this will even override names specified by the user. that's crazy. name = "VALUE_"+(idx++); } else { String facetValue = facet.getValue().value; BIEnumMember mem = members.get(facetValue); if( mem==null ) // look at the one attached to the facet object mem = builder.getBindInfo(facet).get(BIEnumMember.class); if (mem!=null) { name = mem.name; if (mdoc == null) { mdoc = mem.javadoc; } } if(name==null) { StringBuilder sb = new StringBuilder(); for( int i=0; i<facetValue.length(); i++) { char ch = facetValue.charAt(i); if(Character.isJavaIdentifierPart(ch)) sb.append(ch); else sb.append('_'); } name = model.getNameConverter().toConstantName(sb.toString()); } } if(!JJavaName.isJavaIdentifier(name)) { if(errorRef!=null) errorRef[0] = facet; return null; // unable to generate a name } memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator())); } return memberList; }
Example 18
Source File: CodeModelClassFactory.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public JDefinedClass createClass( JClassContainer parent, int mod, String name, Locator source, ClassType kind ) { if(!JJavaName.isJavaIdentifier(name)) { // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_INVALID_CLASSNAME, name ), source )); return createDummyClass(parent); } try { if(parent.isClass() && kind==ClassType.CLASS) mod |= JMod.STATIC; JDefinedClass r = parent._class(mod,name,kind); // use the metadata field to store the source location, // so that we can report class name collision errors. r.metadata = source; return r; } catch( JClassAlreadyExistsException e ) { // class collision. JDefinedClass cls = e.getExistingClass(); // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION, cls.fullName() ), (Locator)cls.metadata )); errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION_SOURCE, name ), source )); if( !name.equals(cls.name()) ) { // on Windows, FooBar and Foobar causes name collision errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CASE_SENSITIVITY_COLLISION, name, cls.name() ), null ) ); } if(Util.equals((Locator)cls.metadata,source)) { errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CHAMELEON_SCHEMA_GONE_WILD ), source )); } return createDummyClass(parent); } }
Example 19
Source File: CodeModelClassFactory.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public JDefinedClass createClass( JClassContainer parent, int mod, String name, Locator source, ClassType kind ) { if(!JJavaName.isJavaIdentifier(name)) { // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_INVALID_CLASSNAME, name ), source )); return createDummyClass(parent); } try { if(parent.isClass() && kind==ClassType.CLASS) mod |= JMod.STATIC; JDefinedClass r = parent._class(mod,name,kind); // use the metadata field to store the source location, // so that we can report class name collision errors. r.metadata = source; return r; } catch( JClassAlreadyExistsException e ) { // class collision. JDefinedClass cls = e.getExistingClass(); // report the error errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION, cls.fullName() ), (Locator)cls.metadata )); errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CLASSNAME_COLLISION_SOURCE, name ), source )); if( !name.equals(cls.name()) ) { // on Windows, FooBar and Foobar causes name collision errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CASE_SENSITIVITY_COLLISION, name, cls.name() ), null ) ); } if(Util.equals((Locator)cls.metadata,source)) { errorReceiver.error( new SAXParseException( Messages.format( Messages.ERR_CHAMELEON_SCHEMA_GONE_WILD ), source )); } return createDummyClass(parent); } }
Example 20
Source File: SimpleTypeBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * * @param errorRef * if constant names couldn't be generated, return a reference to that enum facet. * @return * null if unable to generate names for some of the constants. */ private List<CEnumConstant> buildCEnumConstants(XSRestrictionSimpleType type, boolean needsToGenerateMemberName, Map<String, BIEnumMember> members, XSFacet[] errorRef) { List<CEnumConstant> memberList = new ArrayList<CEnumConstant>(); int idx=1; Set<String> enums = new HashSet<String>(); // to avoid duplicates. See issue #366 for( XSFacet facet : type.getDeclaredFacets(XSFacet.FACET_ENUMERATION)) { String name=null; String mdoc=builder.getBindInfo(facet).getDocumentation(); if(!enums.add(facet.getValue().value)) continue; // ignore the 2nd occasion if( needsToGenerateMemberName ) { // generate names for all member names. // this will even override names specified by the user. that's crazy. name = "VALUE_"+(idx++); } else { String facetValue = facet.getValue().value; BIEnumMember mem = members.get(facetValue); if( mem==null ) // look at the one attached to the facet object mem = builder.getBindInfo(facet).get(BIEnumMember.class); if (mem!=null) { name = mem.name; if (mdoc == null) { mdoc = mem.javadoc; } } if(name==null) { StringBuilder sb = new StringBuilder(); for( int i=0; i<facetValue.length(); i++) { char ch = facetValue.charAt(i); if(Character.isJavaIdentifierPart(ch)) sb.append(ch); else sb.append('_'); } name = model.getNameConverter().toConstantName(sb.toString()); } } if(!JJavaName.isJavaIdentifier(name)) { if(errorRef!=null) errorRef[0] = facet; return null; // unable to generate a name } memberList.add(new CEnumConstant(name,mdoc,facet.getValue().value,facet,builder.getBindInfo(facet).toCustomizationList(),facet.getLocator())); } return memberList; }