Class DocumentTypeManager

java.lang.Object
com.yahoo.document.DocumentTypeManager

public class DocumentTypeManager extends Object
The DocumentTypeManager keeps track of the document types registered in the Vespa common repository. The DocumentTypeManager is also responsible for registering a FieldValue factory for each data type a field can have. The Document object uses this factory to serialize and deserialize the various datatypes. The factory could also be used to expand the functionality of various datatypes, for instance displaying the data type in human-readable form or as XML.
Author:
Thomas Gundersen
  • Constructor Details

    • DocumentTypeManager

      public DocumentTypeManager()
    • DocumentTypeManager

      @Inject public DocumentTypeManager(DocumentmanagerConfig config)
  • Method Details

    • fromFile

      public static DocumentTypeManager fromFile(String fileName)
      Only for unit tests
    • getIgnoreUndefinedFields

      public boolean getIgnoreUndefinedFields()
      Returns true if we should ignore attempts to set a field not defined in the document type, rather than (by default) throwing an exception.
    • setIgnoreUndefinedFields

      public void setIgnoreUndefinedFields(boolean ignoreUndefinedFields)
    • register

      public void register(DataType type)
      Register a data type of any sort, including document types.
      Parameters:
      type - The datatype to register TODO Give unique ids to document types
    • registerDocumentType

      public DocumentType registerDocumentType(DocumentType docType)
      Registers a document type. Typically called by someone importing the document types from the common Vespa repository.
      Parameters:
      docType - The document type to register.
      Returns:
      the previously registered type, or null if none was registered
    • getDocumentType

      public DocumentType getDocumentType(DataTypeName name)
      Gets a registered document.
      Parameters:
      name - the document name of the type
      Returns:
      returns the document type found, or null if there is no type with this name
    • getDocumentType

      public DocumentType getDocumentType(String name)
      Returns a registered document type
      Parameters:
      name - the type name of the document type
      Returns:
      returns the document type having this name, or null if none
    • hasDocumentType

      public boolean hasDocumentType(String name)
      Convenience method
      Parameters:
      name - the name of a document type
      Returns:
      returns true if a document type having this name is registered in this manager
    • createDocument

      public final Document createDocument(com.yahoo.io.GrowableByteBuffer buf)
    • createDocument

      public Document createDocument(DocumentDeserializer data)
    • getDataTypes

      public Collection<DataType> getDataTypes()
      Returns a read only view of the registered data types
      Returns:
      collection of types
    • getDocumentTypes

      public Map<DataTypeName,DocumentType> getDocumentTypes()
      A read only view of the registered document types
      Returns:
      map of types
    • documentTypeIterator

      public Iterator<DocumentType> documentTypeIterator()
    • getAnnotationTypeRegistry

      public AnnotationTypeRegistry getAnnotationTypeRegistry()