public FromHostResult < SpecificRecord > convert(byte[] hostData, int start, int length) { FromHostResult < GenericRecord > result = converter.convert(hostData, start, length); if (result.getValue() == null) { return null; } this.specificRecord = (SpecificRecord) SpecificData.get().deepCopy( result.getValue().getSchema(), result.getValue()); return new FromHostResult < SpecificRecord >( result.getBytesProcessed(), specificRecord); }
@SuppressWarnings("unchecked") public D next() { try { ReadRecordStatus status = readRecord(hostBytes, lastProcessed); bytesRead += status.getBytesRead(); int prefixLen = hostBytesPrefixLen(); FromHostResult < GenericRecord > result = converter.convert( hostBytes, prefixLen, status.getRecordLen() == -1 ? hostBytes.length : status .getRecordLen() + prefixLen); bytesProcessed += lastProcessed = result.getBytesProcessed(); D specific = (D) SpecificData.get().deepCopy( result.getValue().getSchema(), result.getValue()); if (log.isDebugEnabled()) { log.debug("Avro record=" + specific.toString()); } return specific; } catch (IOException e) { throw new AvroRuntimeException(e); } }
/** * Convert host data to a JAXB instance. * <p/> * * @param hostData the buffer of host data * @param start where to start in the buffer of host data * @param length How many bytes of hostData contains actual data to process * @return a result object containing the JAXB instance created as well as * the total number of host bytes used to generate that JAXB * instance */ public FromHostResult < J > convert(byte[] hostData, int start, int length) { Cob2JaxbVisitor visitor = new Cob2JaxbVisitor(getCobolContext(), hostData, start, length, jaxbWrapperFactory); visitor.visit(getCobolComplexType()); JaxbWrapper < ? > jaxbWrapper = visitor .getLastObject(JaxbWrapper.class); return new FromHostResult < J >(visitor.getLastPos(), jaxbClass.cast(jaxbWrapper.getJaxb())); }
public FromHostResult < GenericRecord > convert(byte[] hostData, int start, int length) { Cob2AvroVisitor visitor = new Cob2AvroVisitor(getCobolContext(), hostData, start, length, getCustomChoiceStrategy(), getCustomVariables(), schema); visitor.visit(getCobolComplexType()); return new FromHostResult < GenericRecord >(visitor.getLastPos(), (GenericRecord) visitor.getResultObject()); }
@SuppressWarnings("unchecked") public FromHostResult < Map < String, Object > > convert(byte[] hostData, int start, int length) { Cob2ObjectVisitor visitor = new Cob2ObjectVisitor(getCobolContext(), hostData, start, length, getCustomChoiceStrategy(), getCustomVariables()); visitor.visit(getCobolComplexType()); return new FromHostResult < Map < String, Object > >( visitor.getLastPos(), (Map < String, Object >) visitor.getResultObject()); }