net.jangaroo.exml.model.ConfigAttribute Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of exml-compiler Show documentation
Show all versions of exml-compiler Show documentation
parses an EXML and generates an AS config class
package net.jangaroo.exml.model;
import net.jangaroo.utils.AS3Type;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
/**
* A meta model of an Ext JS component configuration attribute.
*/
public final class ConfigAttribute extends TypedField {
private static final Set SIMPLE_TYPES = new HashSet(Arrays.asList(
AS3Type.BOOLEAN.toString(),
AS3Type.NUMBER.toString(),
AS3Type.INT.toString(),
AS3Type.UINT.toString(),
AS3Type.DATE.toString(),
AS3Type.STRING.toString()
));
private static final Collection SEQUENCE_TYPES = new HashSet(Arrays.asList(
AS3Type.ARRAY.toString(),
"MixedCollection",
"Mixed"));
public ConfigAttribute(String name, String type, String description) {
super(name, type, description);
if(type == null) {
throw new IllegalArgumentException("The type should not be null for config attribute: '" + name + "'");
}
}
/**
* The type used by xsd generation
* @return the xs type
*/
public String getXsType() {
return isSimple() ? getType() : "String";
}
public boolean isSimple() {
return SIMPLE_TYPES.contains(getType());
}
public boolean isSequence() {
return SEQUENCE_TYPES.contains(getType());
}
public boolean isObject() {
return !SIMPLE_TYPES.contains(getType()) && !SEQUENCE_TYPES.contains(getType());
}
@Override
public String toString() {
return getName() + " : " + getType();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy