Package org.apache.sling.feature.cpconverter.index

## Class IndexDefinitions

- java.lang.Object
- - org.apache.sling.feature.cpconverter.index.IndexDefinitions

    public class IndexDefinitions
    extends Object

Holds information about discovered index definitions

According to the Oak documentation, indexes are located under a root `/oak:index`, or (lucene indexes only) under arbitrary repository locations, as long as they have an `oak:index` parent node.

This class supports non-root indexes but does not attempt to enforce Oak-level invariants, such as which index types support non-root locations.

### Field Summary

Fields
`static String` `OAK_INDEX_NAME`
`static String` `OAK_INDEX_PATH`

### Constructor Summary

Constructors
`IndexDefinitions()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addNode​(@NotNull String parentPath, @NotNull org.apache.jackrabbit.vault.util.DocViewNode2 node)`
`void` `dump​(@NotNull PrintStream out)` Dumps a compact representation of the data
`@NotNull Optional<byte[]>` `getBinary​(@NotNull String repositoryPath)` Returns a potential binary registered for a repository path
`@NotNull List<org.apache.jackrabbit.vault.util.DocViewNode2>` `getChildren​(@NotNull String parentPath)`
`@NotNull Map<String,​List<org.apache.jackrabbit.vault.util.DocViewNode2>>` `getIndexes()` Returns the discovered index definitions by location
`void` `registerBinary​(@NotNull String repositoryPath, @NotNull InputStream is)` Registers a binary entry at the specified repository path
`void` `registerPrefixMapping​(@NotNull String prefix, @NotNull String uri)` Registers a prefix mapping for a specified uri
`@NotNull String` `toShortName​(@NotNull org.apache.jackrabbit.spi.Name name)` Returns a name in compact format

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### OAK_INDEX_NAME

    public static final String OAK_INDEX_NAME

See Also:
  Constant Field Values

#### OAK_INDEX_PATH

    public static final String OAK_INDEX_PATH

See Also:
  Constant Field Values

### Constructor Detail

#### IndexDefinitions

    public IndexDefinitions()

### Method Detail

#### addNode

    public void addNode​(@NotNull
                        @NotNull String parentPath,
                        @NotNull
                        @NotNull org.apache.jackrabbit.vault.util.DocViewNode2 node)

#### getIndexes

    @NotNull
    public @NotNull Map<String,​List<org.apache.jackrabbit.vault.util.DocViewNode2>> getIndexes()

Returns the discovered index definitions by location

The returned map has the index parent location as keys and the index definitions as values, for instance:

- oak:index -> [counter, uuid]
- content/oak:index -> [lucene-2]

Returns:
  a map of discovered index locations, possibly empty

#### getChildren

    @NotNull
    public @NotNull List<org.apache.jackrabbit.vault.util.DocViewNode2> getChildren​(@NotNull
                                                                                    @NotNull String parentPath)

#### toShortName

    @NotNull
    public @NotNull String toShortName​(@NotNull
                                       @NotNull org.apache.jackrabbit.spi.Name name)

Returns a name in compact format

Maps a fully qualified `name`, e.g. ['http://jackrabbit.apache.org/oak/ns/1.0','index'] to a compact name like `oak:index`

Parameters:
  `name` - The name to map
Returns:
  the compact name

#### registerBinary

    public void registerBinary​(@NotNull
                               @NotNull String repositoryPath,
                               @NotNull
                               @NotNull InputStream is)
                        throws IOException

Registers a binary entry at the specified repository path

The input stream may be fully read into memory, and therefore is not expected to be unreasonably large.

The input stream will be fully read, but not closed.

Parameters:
  `repositoryPath` - The JCR repository path where the binary was found
  `is` - the input stream for the binary
Throws:
  `IOException` - in case of I/O problems

#### getBinary

    @NotNull
    public @NotNull Optional<byte[]> getBinary​(@NotNull
                                               @NotNull String repositoryPath)

Returns a potential binary registered for a repository path

Parameters:
  `repositoryPath` - the path of the repository
Returns:
  an optional wrapping the binary data, possibly `empty`

#### registerPrefixMapping

    public void registerPrefixMapping​(@NotNull
                                      @NotNull String prefix,
                                      @NotNull
                                      @NotNull String uri)

Registers a prefix mapping for a specified uri

Parameters:
  `prefix` - the prefix
  `uri` - the uri

#### dump

    public void dump​(@NotNull
                     @NotNull PrintStream out)

Dumps a compact representation of the data

Useful for debugging purposes only

Parameters:
  `out` - the PrintStream to use