public boolean isPrimitiveArray() { String type = getType(); for ( String PRIMITIVE_TYPE : PRIMITIVE_TYPES ) { String validType = PRIMITIVE_TYPE + "[]"; if ( validType.equals( type ) ) { return true; } } return false; }
public boolean isArray() { return getType().endsWith( "[]" ); }
public boolean isPrimitive() { String type = getType(); // TODO: This should not happen if ( type == null ) { return false; } for ( String validType : PRIMITIVE_TYPES ) { if ( type.equals( validType ) ) { return true; } } return false; }
private void assertSupportedIdentityPrimitive( ModelField modelField ) throws ModelloException { if ( !PRIMITIVE_IDENTITY_MAP.containsKey( modelField.getType() ) ) { throw new ModelloException( "The JDO mapping generator does not support the specified " + "field type '" + modelField.getType() + "'. " + "Supported types: " + PRIMITIVE_IDENTITY_MAP.keySet() ); } }
private void assertSupportedIdentityPrimitive( ModelField modelField ) throws ModelloException { if ( !PRIMITIVE_IDENTITY_MAP.containsKey( modelField.getType() ) ) { throw new ModelloException( "The JDO mapping generator does not support the specified " + "field type '" + modelField.getType() + "'. " + "Supported types: " + PRIMITIVE_IDENTITY_MAP.keySet() ); } }
public String makeGetter( ModelField field ) { if ( field.getType().equals( "boolean" ) ) { return "is" + field.getName().substring( 0, 1 ).toUpperCase() + field.getName().substring( 1 ); } return "get" + field.getName().substring( 0, 1 ).toUpperCase() + field.getName().substring( 1 ); }
public String makeGetter( ModelField field ) { if ( field.getType().equals( "boolean" ) ) { return "is" + field.getName().substring( 0, 1 ).toUpperCase() + field.getName().substring( 1 ); } return "get" + field.getName().substring( 0, 1 ).toUpperCase() + field.getName().substring( 1 ); }
public String getType() { if ( ONE_MULTIPLICITY.equals( getMultiplicity() ) ) { return getTo(); } else { return super.getType(); } }
private String createHashCodeForField( ModelField identifier ) { String name = identifier.getName(); String type = identifier.getType(); if ( "boolean".equals( type ) ) { return "( " + name + " ? 0 : 1 )"; } else if ( "byte".equals( type ) || "char".equals( type ) || "short".equals( type ) || "int".equals( type ) ) { return "(int) " + name; } else if ( "long".equals( type ) ) { return "(int) ( " + name + " ^ ( " + name + " >>> 32 ) )"; } else if ( "float".equals( type ) ) { return "Float.floatToIntBits( " + name + " )"; } else if ( "double".equals( type ) ) { return "(int) ( Double.doubleToLongBits( " + identifier.getName() + " ) ^ ( Double.doubleToLongBits( " + identifier.getName() + " ) >>> 32 ) )"; } else { return "( " + name + " != null ? " + name + ".hashCode() : 0 )"; } }
protected String getJavaDefaultValue( ModelField modelField ) throws ModelloException String type = modelField.getType(); String value = modelField.getDefaultValue();
public FieldMetadata getFieldMetadata( ModelField field, Map<String, String> data ) { JavaFieldMetadata metadata = new JavaFieldMetadata(); metadata.setGetter( getBoolean( data, JAVA_GETTER, true ) ); String fieldType = field.getType(); metadata.setBooleanGetter( ( fieldType != null ) && fieldType.endsWith( "oolean" ) ); metadata.setSetter( getBoolean( data, JAVA_SETTER, true ) ); return metadata; }
if ( "boolean".equals( identifier.getType() ) || "byte".equals( identifier.getType() ) || "char".equals( identifier.getType() ) || "double".equals( identifier.getType() ) || "float".equals( identifier.getType() ) || "int".equals( identifier.getType() ) || "short".equals( identifier.getType() ) || "long".equals( identifier.getType() ) )
if ( !field.getType().equals( "String" ) )
if ( !field.getType().equals( "String" ) )
private void writeElementAttribute( JSourceCode sc, ModelField referenceIdentifierField, String value ) { if ( referenceIdentifierField instanceof DummyIdModelField ) { writeIdMapCheck( sc, value, referenceIdentifierField.getName() ); } else { String v = getValue( referenceIdentifierField.getType(), getFieldValue( value, referenceIdentifierField ), (XmlFieldMetadata) referenceIdentifierField.getMetadata( XmlFieldMetadata.ID ) ); sc.add( "serializer.writeAttribute( \"" + referenceIdentifierField.getName() + "\", " + v + " );" ); } }
String getter = "boolean".equals( identifier.getType() ) ? "is" : "get";
/** * Add code to parse fields of a model class that are XML attributes. * * @param modelClass the model class * @param uncapClassName * @param sc the source code to add to * @throws ModelloException */ private void writeAttributes( ModelClass modelClass, String uncapClassName, JSourceCode sc ) throws ModelloException { for ( ModelField field : modelClass.getAllFields( getGeneratedVersion(), true ) ) { XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata( XmlFieldMetadata.ID ); if ( xmlFieldMetadata.isAttribute() && !xmlFieldMetadata.isTransient() ) { writePrimitiveField( field, field.getType(), uncapClassName, "set" + capitalise( field.getName() ), sc ); } } }
if ( "Content".equals( field.getType() ) )
if ( !"String".equals( field.getType() ) )
sc.indent(); writePrimitiveField( field, field.getType(), objectName, objectName, "\"" + field.getName() + "\"", "set" + capitalise( field.getName() ), sc );