public static ImmutableDocument wrap(Document document) { return new ImmutableDocument(document.getData()); } }
/** * Creates a deep copy of the raw map in the specified document and wrap it * in a new typed document using the specified constructor. * * @param <DOC> the document type * @param document the document * @param constructor the document constructor * @return the copy */ public static <DOC extends Document> DOC deepCopy( DOC document, Function<Map<String, Object>, DOC> constructor) { return constructor.apply(deepCopyMap(document.getData())); }
/** * Returns a stream of child documents to a specified document by using the * supplied constructor. * * @param <E> the expected child type * @param document the parent document * @param childConstructor child constructor * @return stream of children */ @SuppressWarnings("unchecked") public static <E extends Document> Stream<E> childrenOf( final Document document, final BiFunction<Document, Map<String, Object>, E> childConstructor) { requireNonNull(document); requireNonNull(childConstructor); return document.getData().values().stream() .filter(obj -> obj instanceof List<?>) .map(list -> (List<Object>) list) .flatMap(Collection::stream) .filter(obj -> obj instanceof Map<?, ?>) .map(map -> (Map<String, Object>) map) .map(map -> childConstructor.apply(document, map)); }
/** * Helps documents to format a {@code toString()}-method. * * @param document the document * @return the string */ public static String toStringHelper(Document document) { return document.getClass().getSimpleName() + " {" + MapStream.of(document.getData()) .mapValue(VALUE_MAPPER) .map((k, v) -> "\"" + k + "\": " + (v == null ? "null" : (v instanceof String ? ("\"" + v + "\"") : v.toString()))) .collect(joining(", ")) + "}"; }
/** * Creates a deep copy of the raw map in the specified document and wrap it * in a new typed document using the specified constructor. * * @param <P> the parent type * @param <DOC> the document type * @param document the document * @param constructor the document constructor * @return the copy */ public static <P extends Document, DOC extends Document & HasParent<P>> DOC deepCopy(DOC document, BiFunction<P, Map<String, Object>, DOC> constructor) { return constructor.apply( document.getParent().orElse(null), deepCopyMap(document.getData()) ); }
final Collection<? extends Map<String, Object>> coll; if (doc instanceof Dbms) { coll = (Collection<? extends Map<String, Object>>) parent.getData().get(Project.DBMSES); } else if (doc instanceof Schema) { coll =(Collection<? extends Map<String, Object>>) parent.getData().get(Dbms.SCHEMAS); } else if (doc instanceof Table) { coll = (Collection<? extends Map<String, Object>>) parent.getData().get(Schema.TABLES); } else if (doc instanceof Column) { coll = (Collection<? extends Map<String, Object>>) parent.getData().get(Table.COLUMNS); } else if (doc instanceof PrimaryKeyColumn) { coll = (Collection<? extends Map<String, Object>>) parent.getData().get(Table.PRIMARY_KEY_COLUMNS); } else if (doc instanceof IndexColumn) { coll = (Collection<? extends Map<String, Object>>) parent.getData().get(Index.INDEX_COLUMNS); } else if (doc instanceof ForeignKeyColumn) { coll = (Collection<? extends Map<String, Object>>) parent.getData().get(ForeignKey.FOREIGN_KEY_COLUMNS); } else if (doc instanceof ForeignKey) { coll = (Collection<? extends Map<String, Object>>) parent.getData().get(ForeignKey.FOREIGN_KEY_COLUMNS); } else if (doc instanceof Index) { coll = (Collection<? extends Map<String, Object>>) parent.getData().get(Table.INDEXES); } else { getLog().error("Doc was of type " + doc.getClass()); doc.getData().put(param, newValue); edits.increment();
document.getData(), mainInterface );
TikaInputStream inputStream = TikaInputStream.get(p_document.getData(), metadata);