public String getString(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.STRING_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.STRING_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); if (nullFlags[nullPos]) { return DataTypes.STRING_TYPE.nullValue(); } return strings[pos]; }
@Override public String convert(Object val, Multiplicity m) throws AtlasException { if (val != null && (!(val instanceof String) || StringUtils.isNotEmpty((CharSequence) val))) { return val.toString(); } if (m.nullAllowed() && val != null){ return val.toString(); } return convertNull(m); }
new AttributeDefinition("b", DataTypes.arrayTypeName(DataTypes.STRING_TYPE.getName()), Multiplicity.COLLECTION, false, null)); try {
new AttributeDefinition("b", DataTypes.arrayTypeName(DataTypes.STRING_TYPE.getName()), Multiplicity.COLLECTION, false, null)); try {
private IdType() { AttributeDefinition idAttr = new AttributeDefinition(ID_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, null); AttributeDefinition typNmAttr = new AttributeDefinition(TYPENAME_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, null); AttributeDefinition stateAttr = new AttributeDefinition(STATE_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, null); AttributeDefinition versionAttr = new AttributeDefinition(VERSION_ATTRNAME, DataTypes.INT_TYPE.getName(), Multiplicity.REQUIRED, false, null); try { AttributeInfo[] infos = new AttributeInfo[4]; infos[0] = new AttributeInfo(TypeSystem.this, idAttr, null); infos[1] = new AttributeInfo(TypeSystem.this, typNmAttr, null); infos[2] = new AttributeInfo(TypeSystem.this, stateAttr, null); infos[3] = new AttributeInfo(TypeSystem.this, versionAttr, null); type = new StructType(TypeSystem.this, TYP_NAME, null, infos); } catch (AtlasException me) { throw new RuntimeException(me); } }
private IdType() { AttributeDefinition idAttr = new AttributeDefinition(ID_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, null); AttributeDefinition typNmAttr = new AttributeDefinition(TYPENAME_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, null); AttributeDefinition stateAttr = new AttributeDefinition(STATE_ATTRNAME, DataTypes.STRING_TYPE.getName(), Multiplicity.REQUIRED, false, null); AttributeDefinition versionAttr = new AttributeDefinition(VERSION_ATTRNAME, DataTypes.INT_TYPE.getName(), Multiplicity.REQUIRED, false, null); try { AttributeInfo[] infos = new AttributeInfo[4]; infos[0] = new AttributeInfo(TypeSystem.this, idAttr, null); infos[1] = new AttributeInfo(TypeSystem.this, typNmAttr, null); infos[2] = new AttributeInfo(TypeSystem.this, stateAttr, null); infos[3] = new AttributeInfo(TypeSystem.this, versionAttr, null); type = new StructType(TypeSystem.this, TYP_NAME, null, infos); } catch (AtlasException me) { throw new RuntimeException(me); } }
public String getString(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.STRING_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, getTypeName(), DataTypes.STRING_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); if (nullFlags[nullPos]) { return DataTypes.STRING_TYPE.nullValue(); } return strings[pos]; }
public void setString(String attrName, String val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.STRING_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.STRING_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = val == null; strings[pos] = val; explicitSets[nullPos] = true; }
public void setString(String attrName, String val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.STRING_TYPE) { throw new AtlasException( String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, getTypeName(), DataTypes.STRING_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = val == null; strings[pos] = val; explicitSets[nullPos] = true; }
private void registerPrimitiveTypes() { coreTypes.put(DataTypes.BOOLEAN_TYPE.getName(), DataTypes.BOOLEAN_TYPE); coreTypes.put(DataTypes.BYTE_TYPE.getName(), DataTypes.BYTE_TYPE); coreTypes.put(DataTypes.SHORT_TYPE.getName(), DataTypes.SHORT_TYPE); coreTypes.put(DataTypes.INT_TYPE.getName(), DataTypes.INT_TYPE); coreTypes.put(DataTypes.LONG_TYPE.getName(), DataTypes.LONG_TYPE); coreTypes.put(DataTypes.FLOAT_TYPE.getName(), DataTypes.FLOAT_TYPE); coreTypes.put(DataTypes.DOUBLE_TYPE.getName(), DataTypes.DOUBLE_TYPE); coreTypes.put(DataTypes.BIGINTEGER_TYPE.getName(), DataTypes.BIGINTEGER_TYPE); coreTypes.put(DataTypes.BIGDECIMAL_TYPE.getName(), DataTypes.BIGDECIMAL_TYPE); coreTypes.put(DataTypes.DATE_TYPE.getName(), DataTypes.DATE_TYPE); coreTypes.put(DataTypes.STRING_TYPE.getName(), DataTypes.STRING_TYPE); }
private void registerPrimitiveTypes() { coreTypes.put(DataTypes.BOOLEAN_TYPE.getName(), DataTypes.BOOLEAN_TYPE); coreTypes.put(DataTypes.BYTE_TYPE.getName(), DataTypes.BYTE_TYPE); coreTypes.put(DataTypes.SHORT_TYPE.getName(), DataTypes.SHORT_TYPE); coreTypes.put(DataTypes.INT_TYPE.getName(), DataTypes.INT_TYPE); coreTypes.put(DataTypes.LONG_TYPE.getName(), DataTypes.LONG_TYPE); coreTypes.put(DataTypes.FLOAT_TYPE.getName(), DataTypes.FLOAT_TYPE); coreTypes.put(DataTypes.DOUBLE_TYPE.getName(), DataTypes.DOUBLE_TYPE); coreTypes.put(DataTypes.BIGINTEGER_TYPE.getName(), DataTypes.BIGINTEGER_TYPE); coreTypes.put(DataTypes.BIGDECIMAL_TYPE.getName(), DataTypes.BIGDECIMAL_TYPE); coreTypes.put(DataTypes.DATE_TYPE.getName(), DataTypes.DATE_TYPE); coreTypes.put(DataTypes.STRING_TYPE.getName(), DataTypes.STRING_TYPE); }
@Override public String convert(Object val, Multiplicity m) throws AtlasException { if (val != null && (!(val instanceof String) || StringUtils.isNotEmpty((CharSequence) val))) { return val.toString(); } if (m.nullAllowed() && val != null){ return val.toString(); } return convertNull(m); }