## org.exist.validation.internal
Class DatabaseResources

    java.lang.Object
      org.exist.validation.internal.DatabaseResources

public class DatabaseResources
extends java.lang.Object

Helper class for accessing grammars.

Author:
  Dannes Wessels

Field Summary
`static java.lang.String` `CATALOG`
`static java.lang.String` `FIND_DTD_IN_CATALOG`
`static java.lang.String` `FIND_PUBLICID_IN_CATALOGS`
`static java.lang.String` `FIND_XSD`
`static java.lang.String` `FIND_XSD_IN_CATALOG`
`static java.lang.String` `PUBLICID`
`static java.lang.String` `TARGETNAMESPACE`

Constructor Summary
`DatabaseResources(BrokerPool pool)` Creates a new instance of DatabaseResources.

Method Summary
`Sequence` `executeQuery(XmldbURI collection, java.util.Map params, java.lang.String queryPath)` Execute query with supplied parameters.
`java.util.List` `getAllResults(Sequence sequence)` Convert sequence into list of strings.
`static java.lang.String` `getCollectionPath(java.lang.String path)` Get collection pathname from path.
`static java.lang.String` `getDocumentName(java.lang.String path)` Get document name from path.
`java.lang.String` `getDtdPath(XmldbURI collection, java.lang.String publicId)` Find document catalogPath of DTD describing a publicId.
`java.lang.String` `getDtdPathFromCatalog(XmldbURI collection, java.lang.String docName, java.lang.String publicId)` Get DTD path information from catalog.
`java.lang.String` `getFirstResult(Sequence sequence)` Get first entry of sequence as String.
`byte[]` `getResource(java.lang.String documentPath)` Get document from database.
`java.lang.String` `getSchemaPath(XmldbURI collection, java.lang.String namespace)` Find document path of XSD describing a namespace.
`java.lang.String` `getSchemaPathFromCatalog(XmldbURI collection, java.lang.String docName, java.lang.String namespace)` Get schema path information from catalog.
`boolean` `insertResource(java.lang.String documentPath, byte[] grammar)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FIND_XSD

    public static java.lang.String FIND_XSD

### FIND_PUBLICID_IN_CATALOGS

    public static java.lang.String FIND_PUBLICID_IN_CATALOGS

### FIND_XSD_IN_CATALOG

    public static java.lang.String FIND_XSD_IN_CATALOG

### FIND_DTD_IN_CATALOG

    public static java.lang.String FIND_DTD_IN_CATALOG

### PUBLICID

    public static java.lang.String PUBLICID

### TARGETNAMESPACE

    public static java.lang.String TARGETNAMESPACE

### CATALOG

    public static java.lang.String CATALOG

Constructor Detail

### DatabaseResources

    public DatabaseResources(BrokerPool pool)

  Creates a new instance of DatabaseResources.

Parameters:
  `pool` - Instance shared broker pool.

Method Detail

### getAllResults

    public java.util.List getAllResults(Sequence sequence)

  Convert sequence into list of strings. Java5 would make this method more safe to use.

  Parameters:
    `sequence` - Result of query.
  Returns:
    List containing String objects.

### getFirstResult

    public java.lang.String getFirstResult(Sequence sequence)

  Get first entry of sequence as String. Java5 would make this method more safe to use.

  Parameters:
    `sequence` - Result of query.
  Returns:
    String containing representation of 1st entry of sequence.

### executeQuery

    public Sequence executeQuery(XmldbURI collection,
                                 java.util.Map params,
                                 java.lang.String queryPath)

  Execute query with supplied parameters. namespace, publicId, catalogPath,

  Parameters:
    `collection` - Collection in which query is executed.
    `params` - Map of parameters used in cquery
    `queryPath` - Path to xquery in classpath
  Returns:
    Result of xQuery

### getSchemaPath

    public java.lang.String getSchemaPath(XmldbURI collection,
                                          java.lang.String namespace)

  Find document path of XSD describing a namespace.

  Parameters:
    `collection` - Start point for search, e.g. '/db'.
    `namespace` - Namespace that needs to be found.
  Returns:
    Document path (e.g. '/db/foo/bar.xsd') if found, null if namespace could not be found.

### getDtdPath

    public java.lang.String getDtdPath(XmldbURI collection,
                                       java.lang.String publicId)

  Find document catalogPath of DTD describing a publicId.

  Parameters:
    `collection` - Start point for search, e.g. '/db'.
    `publicId` - PublicID that needs to be found.
  Returns:
    Document catalogPath (e.g. '/db/foo/bar.dtd') if found, null if publicID could not be found.

### getResource

    public byte[] getResource(java.lang.String documentPath)

  Get document from database.

  Parameters:
    `documentPath` - Path to the resource.
  Returns:
    Byte array of resource, null if not found.

### insertResource

    public boolean insertResource(java.lang.String documentPath,
                                  byte[] grammar)

### getDocumentName

    public static java.lang.String getDocumentName(java.lang.String path)

  Get document name from path. /db/foo/bar/doc.xml gives doc.xml xmldb:exist:///db/fo/bar/doc.xml gives doc.xml

  Parameters:
    `path` - The Path
  Returns:
    Document name.

### getCollectionPath

    public static java.lang.String getCollectionPath(java.lang.String path)

  Get collection pathname from path. /db/foo/bar/doc.xml gives /db/foo/bar xmldb:exist:///db/fo/bar/doc.xml gives xmldb:exist:///db/fo/bar

  Parameters:
    `path` - The Path
  Returns:
    Collection path name, "" if none available (doc.xml)

### getSchemaPathFromCatalog

    public java.lang.String getSchemaPathFromCatalog(XmldbURI collection,
                                                     java.lang.String docName,
                                                     java.lang.String namespace)

  Get schema path information from catalog.

  Parameters:
    `collection` - Collection containing the catalog file
    `docName` - Catalog filename
    `namespace` - This namespace needs to be resolved
  Returns:
    Path to schema, or null if not found.

### getDtdPathFromCatalog

    public java.lang.String getDtdPathFromCatalog(XmldbURI collection,
                                                  java.lang.String docName,
                                                  java.lang.String publicId)

  Get DTD path information from catalog.

  Parameters:
    `collection` - Collection containing the catalog file
    `docName` - Catalog filename
    `publicId` - This publicId needs to be resolved
  Returns:
    Path to DTD, or null if not found.

Copyright (C) Wolfgang Meier. All rights reserved.