org.openanzo.common.rdb.layout
Class NodeLiteralLayout

java.lang.Object
  extended by org.openanzo.common.rdb.layout.NodeLayoutBase<org.openrdf.model.Literal>
      extended by org.openanzo.common.rdb.layout.NodeLiteralLayout
All Implemented Interfaces:
INodeLayout<org.openrdf.model.Literal>

public class NodeLiteralLayout
extends NodeLayoutBase<org.openrdf.model.Literal>

Layout for Node_Literal type. Based on NodeLayoutBase which enables long node support and aggregates two ValueLayouts for literal datatype and language support.

Author:
Joe Betz, Stephen Evanchik

Constructor Summary
NodeLiteralLayout(LiteralIndexer literalIndexer, SQLCache sqlCache, Sequence sequence, java.lang.String sequenceName, java.lang.String longSequenceName, java.lang.String tableName, java.lang.String longTableName, java.lang.String resourceTempTableName, java.lang.String idTempTableName, int maxLength, java.lang.String optimizationString, IValueLayout datatypeLayout, IValueLayout languageLayout, NodeCentricSchema.LiteralNode literalSchema, NodeCentricSchema.LongLiteralNode longLiteralSchema)
          Create a new NodeLiteralLayout
 
Method Summary
 org.openrdf.model.Literal convert(java.lang.String valueIn, java.lang.Long modifierId)
          Convert raw value from database into Node of appropriate type
 java.lang.Long fetchId(org.openrdf.model.Literal literal)
          Fetches a node's ID from the database
 org.openrdf.model.Literal fetchValue(java.lang.Long id)
          Fetches a nodes value from the database based on its long identifier and NodeType.
 NodeType getType()
           
 boolean isLong(org.openrdf.model.Literal n)
          Determines whether or not a node is 'long'
 java.util.Map<java.lang.Long,org.openrdf.model.Literal> resolveStoredIds(java.util.Set<java.lang.Long> ids)
          This method will determine which IDs in a list of given Ids are already stored in the database.
 java.util.Map<org.openrdf.model.Literal,java.lang.Long> resolveStoredNodes(java.util.Set<org.openrdf.model.Literal> nodes, boolean storeUnresolvedNodes)
          This method will determine which nodes in a list of given nodes are already stored in the database.
 java.lang.Long store(org.openrdf.model.Literal literal)
          Stores a node in the database
 
Methods inherited from class org.openanzo.common.rdb.layout.NodeLayoutBase
getLongSequenceName, getSequenceName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeLiteralLayout

public NodeLiteralLayout(LiteralIndexer literalIndexer,
                         SQLCache sqlCache,
                         Sequence sequence,
                         java.lang.String sequenceName,
                         java.lang.String longSequenceName,
                         java.lang.String tableName,
                         java.lang.String longTableName,
                         java.lang.String resourceTempTableName,
                         java.lang.String idTempTableName,
                         int maxLength,
                         java.lang.String optimizationString,
                         IValueLayout datatypeLayout,
                         IValueLayout languageLayout,
                         NodeCentricSchema.LiteralNode literalSchema,
                         NodeCentricSchema.LongLiteralNode longLiteralSchema)
Create a new NodeLiteralLayout

Parameters:
literalIndexer - Optional literal indexer
sqlCache - SQLCache from underlying connection
sequence - Sequence for getting IDs for literals
sequenceName - Name of sequence for getting IDs for literals
longSequenceName - Name of sequence for getting IDs for long literals
tableName - Name of table where literals are stored
longTableName - Name of table where long literals are stored
resourceTempTableName - Name of temporary table used during insertion and resolving of ids
idTempTableName - Name of temporary table used to resolve values
maxLength - The maximum length of a node's string representation before it is considered long
optimizationString - Extra parameters added to queries for database specific optimizations
datatypeLayout - The layout that contains Datatype data
languageLayout - The layout that contains Language data
literalSchema - Schema for literals
longLiteralSchema - Schema for long literals
Method Detail

store

public java.lang.Long store(org.openrdf.model.Literal literal)
Description copied from interface: INodeLayout
Stores a node in the database

Parameters:
literal - The node to be stored
Returns:
The ID of the node stored

isLong

public boolean isLong(org.openrdf.model.Literal n)
Description copied from class: NodeLayoutBase
Determines whether or not a node is 'long'

Overrides:
isLong in class NodeLayoutBase<org.openrdf.model.Literal>
Parameters:
n - The node to test
Returns:
true if the node is a long node, false otherwise

fetchValue

public org.openrdf.model.Literal fetchValue(java.lang.Long id)
Description copied from interface: INodeLayout
Fetches a nodes value from the database based on its long identifier and NodeType.

Parameters:
id - The ID of the node to be found
Returns:
The node

convert

public org.openrdf.model.Literal convert(java.lang.String valueIn,
                                         java.lang.Long modifierId)
Description copied from interface: INodeLayout
Convert raw value from database into Node of appropriate type

Parameters:
valueIn - raw value of node from database
modifierId - for literal values
Returns:
converted Node of appropriate type

fetchId

public java.lang.Long fetchId(org.openrdf.model.Literal literal)
Description copied from interface: INodeLayout
Fetches a node's ID from the database

Specified by:
fetchId in interface INodeLayout<org.openrdf.model.Literal>
Overrides:
fetchId in class NodeLayoutBase<org.openrdf.model.Literal>
Parameters:
literal - The node who's ID is to be found
Returns:
The ID of the node or null if not found

getType

public NodeType getType()
Returns:
type of Nodes this layout handles

resolveStoredIds

public java.util.Map<java.lang.Long,org.openrdf.model.Literal> resolveStoredIds(java.util.Set<java.lang.Long> ids)
Description copied from interface: INodeLayout
This method will determine which IDs in a list of given Ids are already stored in the database.

Parameters:
ids - The ids which need to be resolved to whether they are already stored.
Returns:
A Map of the ids already stored in the database.

resolveStoredNodes

public java.util.Map<org.openrdf.model.Literal,java.lang.Long> resolveStoredNodes(java.util.Set<org.openrdf.model.Literal> nodes,
                                                                                  boolean storeUnresolvedNodes)
Description copied from interface: INodeLayout
This method will determine which nodes in a list of given nodes are already stored in the database. If storeUnresolvedNodes is true, then any node that is unresolved will be stored.

Parameters:
nodes - The nodes which need to be resolved to whether they are already stored or need to be stored.
storeUnresolvedNodes - Store nodes that are not already stored
Returns:
A Map of the nodes already stored in the database.


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.