/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.metamodel.data; import java.util.Map; import org.apache.metamodel.convert.DocumentConverter; /** * Represents a document, ie. an object to be turned into a {@link Row} using a * {@link DocumentConverter} and to be sourced by a {@link DocumentSource}. * * A document does not require any schema. A document will hold key/value pairs * where keys are always strings, but values may be arbitrary values. */ public class Document { private final Map<String, ?> _values; private final Object _sourceObject; private final String _sourceCollectionName; public Document(Map<String, ?> values, Object sourceObject) { this(null, values, sourceObject); } public Document(String sourceCollectionName, Map<String, ?> values, Object sourceObject) { _sourceCollectionName = sourceCollectionName; _values = values; _sourceObject = sourceObject; } /** * Gets the values of the document. * * @return */ public Map<String, ?> getValues() { return _values; } /** * Gets the source representation of the document, if any. * * @return */ public Object getSourceObject() { return _sourceObject; } /** * Gets the collection/table name as defined in the source, or a hint about * a table name of this document. This method may return null if the * {@link DocumentSource} does not have any knowledge about the originating * collection name, or if there is no logical way to determine such a name. * * @return */ public String getSourceCollectionName() { return _sourceCollectionName; } }