@Override public Annotation create(InputStream stream, String encoding) throws IOException { try { Pair<Annotation, InputStream> pair = serializer.read(stream); pair.second.close(); Annotation annotation = pair.first; return annotation; } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
/** * Read in a CoreDocument from this input stream. * * @param is The input stream to read a CoreDocument's annotation from * @return A pair with the CoreDocument and the input stream * @throws IOException * @throws ClassNotFoundException * @throws ClassCastException */ public Pair<CoreDocument, InputStream> readCoreDocument(InputStream is) throws IOException, ClassNotFoundException, ClassCastException { Pair<Annotation, InputStream> readPair = read(is); CoreDocument readCoreDocument = new CoreDocument(readPair.first()); return new Pair<CoreDocument, InputStream>(readCoreDocument, is); }
String inputSerializerName = props.getProperty("inputSerializer", ProtobufAnnotationSerializer.class.getName()); AnnotationSerializer serializer = MetaClass.create(inputSerializerName).createInstance(); Pair<Annotation, InputStream> pair = serializer.read(httpExchange.getRequestBody()); return pair.first; default:
AnnotationSerializer inputSerializer = loadSerializer(inputSerializerClass, inputSerializerName, properties); InputStream is = new BufferedInputStream(new FileInputStream(file)); Pair<Annotation, InputStream> pair = inputSerializer.read(is); pair.second.close(); annotation = pair.first;
/** * Read in a CoreDocument from this input stream. * * @param is The input stream to read a CoreDocument's annotation from * @return A pair with the CoreDocument and the input stream * @throws IOException * @throws ClassNotFoundException * @throws ClassCastException */ public Pair<CoreDocument, InputStream> readCoreDocument(InputStream is) throws IOException, ClassNotFoundException, ClassCastException { Pair<Annotation, InputStream> readPair = read(is); CoreDocument readCoreDocument = new CoreDocument(readPair.first()); return new Pair<CoreDocument, InputStream>(readCoreDocument, is); }
String inputSerializerName = props.getProperty("inputSerializer", ProtobufAnnotationSerializer.class.getName()); AnnotationSerializer serializer = MetaClass.create(inputSerializerName).createInstance(); Pair<Annotation, InputStream> pair = serializer.read(httpExchange.getRequestBody()); return pair.first; default:
AnnotationSerializer inputSerializer = loadSerializer(inputSerializerClass, inputSerializerName, properties); InputStream is = new BufferedInputStream(new FileInputStream(file)); Pair<Annotation, InputStream> pair = inputSerializer.read(is); pair.second.close(); annotation = pair.first;
AnnotationSerializer inputSerializer = loadSerializer(inputSerializerClass, inputSerializerName, properties); InputStream is = new BufferedInputStream(new FileInputStream(file)); Pair<Annotation, InputStream> pair = inputSerializer.read(is); pair.second.close(); annotation = pair.first;