use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class OsnReader method skipToFirstRecord.
/**
* Skip all objects and attributes until the first object in the collection.
*
* @return True if an object was found.
* @throws IOException If an I/O error occurs.
*/
private boolean skipToFirstRecord() throws IOException {
if (this.osnIterator.next() == OsnIterator.START_DEFINITION) {
final String typePath = this.osnIterator.getPathValue();
final RecordDefinitionImpl type = (RecordDefinitionImpl) this.recordDefinitionFactory.getRecordDefinition(typePath);
final RecordDefinition spatialDataSetType = this.recordDefinitionFactory.getRecordDefinition("/SpatialDataSet");
if (type != null && type.isInstanceOf(spatialDataSetType)) {
final String oiName = this.osnIterator.nextFieldName();
if (oiName != null && oiName.equals("objectIdentifier")) {
this.osnIterator.nextStringValue();
final String fieldName = this.osnIterator.nextFieldName();
if (fieldName != null && (fieldName.equals("geoComponents") || fieldName.equals("annotationComponents"))) {
if (this.osnIterator.next() == OsnIterator.START_SET) {
return true;
} else {
this.osnIterator.throwParseError("Expecting a set of objects");
}
} else {
this.osnIterator.throwParseError("Excepecting the 'geoComponents' attribute");
}
} else {
this.osnIterator.throwParseError("Expecting the 'objectIdentifier' attribute");
}
} else {
return true;
}
} else {
this.osnIterator.throwParseError("Expecting a start of an object definition");
}
return false;
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class OsnReader method getRecord.
private Object getRecord() {
final String typePath = this.osnIterator.getPathValue();
final OsnConverter converter = this.converters.getConverter(typePath);
if (converter != null) {
return converter.read(this.osnIterator);
} else {
final RecordDefinition type = this.recordDefinitionFactory.getRecordDefinition(typePath);
final Record record = this.factory.newRecord(type);
while (this.osnIterator.next() != OsnIterator.END_OBJECT) {
addField(record);
}
return record;
}
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class SaifSchemaReader method getDefinition.
private Object getDefinition(final CsnIterator iterator) throws IOException {
while (iterator.next() != CsnIterator.END_DEFINITION) {
switch(iterator.getEventType()) {
case CsnIterator.CLASS_NAME:
final String superClassName = iterator.getPathValue();
if (superClassName.equals("/Enumeration")) {
final DataType enumeration = processEnumeration(iterator);
nameTypeMap.put(enumeration.getName(), enumeration);
return enumeration;
}
final RecordDefinition superClass = this.schema.getRecordDefinition(superClassName);
if (superClass == null) {
throw new IllegalStateException("Cannot find super class '" + superClassName + "'");
}
this.currentSuperClasses.add(superClass);
break;
case CsnIterator.COMPONENT_NAME:
final String componentName = iterator.getStringValue();
try {
final Method method = getClass().getMethod(componentName, new Class[] { RecordDefinition.class, CsnIterator.class });
method.invoke(this, new Object[] { this.currentClass, iterator });
} catch (final SecurityException e) {
throw new IllegalStateException("Unknown component '" + componentName + "'");
} catch (final NoSuchMethodException e) {
throw new IllegalStateException("Unknown component '" + componentName + "'");
} catch (final IllegalAccessException e) {
throw new RuntimeException(e.getMessage(), e);
} catch (final InvocationTargetException e) {
final Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else if (cause instanceof Error) {
throw (Error) cause;
} else if (cause instanceof IOException) {
throw (IOException) cause;
} else {
throw new RuntimeException(cause.getMessage(), cause);
}
}
default:
break;
}
}
return this.currentClass;
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class Value method setFieldDefinition.
@Override
public void setFieldDefinition(final FieldDefinition field) {
if (field != null) {
this.fieldDefinition = field;
if (field instanceof JdbcFieldDefinition) {
this.jdbcField = (JdbcFieldDefinition) field;
} else {
this.jdbcField = JdbcFieldDefinition.newFieldDefinition(this.queryValue);
}
CodeTable codeTable = null;
if (field != null) {
final RecordDefinition recordDefinition = field.getRecordDefinition();
if (recordDefinition != null) {
final String fieldName = field.getName();
codeTable = recordDefinition.getCodeTableByFieldName(fieldName);
if (codeTable instanceof CodeTableProperty) {
final CodeTableProperty codeTableProperty = (CodeTableProperty) codeTable;
if (codeTableProperty.getRecordDefinition() == recordDefinition) {
codeTable = null;
}
}
if (codeTable != null) {
final Identifier id = codeTable.getIdentifier(this.queryValue);
if (id == null) {
this.displayValue = this.queryValue;
} else {
setQueryValue(id);
final List<Object> values = codeTable.getValues(id);
if (values.size() == 1) {
this.displayValue = values.get(0);
} else {
this.displayValue = Strings.toString(":", values);
}
}
}
}
}
}
}
use of com.revolsys.record.schema.RecordDefinition in project com.revolsys.open by revolsys.
the class Query method equal.
public static Query equal(final FieldDefinition field, final Object value) {
final RecordDefinition recordDefinition = field.getRecordDefinition();
final Query query = new Query(recordDefinition);
final Value valueCondition = new Value(field, value);
final BinaryCondition equal = Q.equal(field, valueCondition);
query.setWhereCondition(equal);
return query;
}
Aggregations