/** * This method transforms a value of the source type into a value * of the target type. * @param value Incoming value of source type * @return Outgoing value of target type * @throws TransformationException if value is an incorrect input type or * the transformation fails */ public Object transformDirect(Object value) throws TransformationException { JsonType json = (JsonType)value; ClobType clob = new ClobType(json.getReference()); clob.setType(Type.JSON); return clob; }
/** * This method transforms a value of the source type into a value * of the target type. * @param value Incoming value of source type * @return Outgoing value of target type * @throws TransformationException if value is an incorrect input type or * the transformation fails */ public Object transformDirect(Object value) throws TransformationException { JsonType json = (JsonType)value; ClobType clob = new ClobType(json.getReference()); clob.setType(Type.JSON); return clob; }
public ClobType close(CommandContext cc) throws TeiidProcessingException { try { writer.close(); } catch (IOException e) { remove(); throw new TeiidProcessingException(QueryPlugin.Event.TEIID30442, e); } if (fsisf.getStorageMode() == StorageMode.MEMORY) { //detach if just in memory byte[] bytes = fsisf.getMemoryBytes(); fsisf.free(); ClobType result = new ClobType(new ClobImpl(new String(bytes, Streamable.CHARSET))); result.setType(Type.JSON); return result; } ClobType result = new ClobType(new ClobImpl(fsisf, -1)); if (cc != null) { cc.addCreatedLob(fsisf); } result.setType(Type.JSON); return result; }
@TeiidFunction(category=FunctionCategoryConstants.JSON) public static ClobType jsonParse(ClobType val, boolean wellformed) throws SQLException, IOException, ParseException { Reader r = null; if (val.getType() == Type.JSON) { return val; } if (!wellformed) { r = val.getCharacterStream(); } try { if (!wellformed) { JSONParser parser = new JSONParser(); parser.parse(r, validatingContentHandler); } ClobType ct = new ClobType(val.getReference()); ct.setType(Type.JSON); return ct; } finally { if (r != null) { r.close(); } } }
public static ClobType geometryToGeoJson(GeometryType geometry) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); GeoJSONWriter writer = new GeoJSONWriter(); try { GeoJSON geoJson = writer.write(jtsGeometry); ClobType result = new ClobType(new ClobImpl(geoJson.toString())); result.setType(Type.JSON); return result; } catch (Exception e) { throw new FunctionExecutionException(e); } }
public static ClobType geometryToGeoJson(GeometryType geometry) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); GeoJSONWriter writer = new GeoJSONWriter(); try { GeoJSON geoJson = writer.write(jtsGeometry); ClobType result = new ClobType(new ClobImpl(geoJson.toString())); result.setType(Type.JSON); return result; } catch (Exception e) { throw new FunctionExecutionException(e); } }
public static ClobType geometryToGeoJson(GeometryType geometry) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); GeoJSONWriter writer = new GeoJSONWriter(); try { GeoJSON geoJson = writer.write(jtsGeometry); ClobType result = new ClobType(new ClobImpl(geoJson.toString())); result.setType(Type.JSON); return result; } catch (Exception e) { throw new FunctionExecutionException(e); } }
@TeiidFunction(category=FunctionCategoryConstants.JSON) public static ClobType jsonParse(BlobType val, boolean wellformed) throws SQLException, IOException, ParseException { InputStreamReader r = XMLSystemFunctions.getJsonReader(val); try { if (!wellformed) { JSONParser parser = new JSONParser(); parser.parse(r, validatingContentHandler); } ClobImpl clobImpl = new ClobImpl(); clobImpl.setStreamFactory(new InputStreamFactory.BlobInputStreamFactory(val.getReference())); clobImpl.setEncoding(r.getEncoding()); ClobType ct = new ClobType(clobImpl); ct.setType(Type.JSON); return ct; } finally { r.close(); } }