org.openjena.atlas.lib
Class ColumnMap

java.lang.Object
  extended by org.openjena.atlas.lib.ColumnMap

public class ColumnMap
extends Object

General descriptor of a reordering (mapping) of columns in tuples to columns in indexes, for example, from triples to triple index order. Naming: map is convert to the reordered form, fetch is get back.


Constructor Summary
ColumnMap(String label, int... elements)
          Construct a column map - the elements are the mappings of a tuple originally in the order 0,1,2,...
ColumnMap(String label, List<T> input, List<T> output)
           
ColumnMap(String input, String output)
          Construct a column mapping that maps the input (one col, one char) to the output
ColumnMap(String label, T[] input, T[] output)
           
 
Method Summary
<T> T
fetchSlot(int idx, T[] tuple)
          Apply to an unmapped tuple to get the i'th slot after mapping : SPO->POS : 0'th slot is P from SPO
<T> T
fetchSlot(int idx, Tuple<T> tuple)
          Apply to an unmapped tuple to get the i'th slot after mapping : SPO->POS : 0'th slot is P from SPO
 int fetchSlotIdx(int idx)
          Get the index of the i'th slot as it appears from a mapping : for SPO->POS : 0'th slot is P so 1->0
 String getLabel()
           
 int length()
          Length of mapping
<T> Tuple<T>
map(Tuple<T> src)
          Apply to an unmapped tuple to get a tuple with the column mapping applied
 String mapName(String word)
          Reorder the letters of a string by the same rules as this column map (forward, map direction)
<T> T
mapSlot(int idx, T[] tuple)
          Apply to a mapped tuple to get the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS
<T> T
mapSlot(int idx, Tuple<T> tuple)
          Apply to a mapped tuple to get the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS
 int mapSlotIdx(int idx)
          Get the index of the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS so 2->0
 String toString()
           
<T> Tuple<T>
unmap(Tuple<T> src)
          Apply to a mapped tuple to get a tuple with the column mapping reverse-applied
 String unmapName(String word)
          Reorder the letters of a string by the same rules as this column map (backward, fetch direction)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColumnMap

public ColumnMap(String input,
                 String output)
Construct a column mapping that maps the input (one col, one char) to the output


ColumnMap

public ColumnMap(String label,
                 List<T> input,
                 List<T> output)

ColumnMap

public ColumnMap(String label,
                 T[] input,
                 T[] output)

ColumnMap

public ColumnMap(String label,
                 int... elements)
Construct a column map - the elements are the mappings of a tuple originally in the order 0,1,2,... so SPO->POS is 2,0,1 (SPO->POS so S->2, P->0, O->1) and not 1,2,0 (which is the extraction mapping). The label is just a lable and is not interpretted.

Method Detail

length

public int length()
Length of mapping


fetchSlot

public <T> T fetchSlot(int idx,
                       Tuple<T> tuple)
Apply to an unmapped tuple to get the i'th slot after mapping : SPO->POS : 0'th slot is P from SPO


fetchSlot

public <T> T fetchSlot(int idx,
                       T[] tuple)
Apply to an unmapped tuple to get the i'th slot after mapping : SPO->POS : 0'th slot is P from SPO


mapSlot

public <T> T mapSlot(int idx,
                     Tuple<T> tuple)
Apply to a mapped tuple to get the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS


mapSlot

public <T> T mapSlot(int idx,
                     T[] tuple)
Apply to a mapped tuple to get the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS


mapSlotIdx

public int mapSlotIdx(int idx)
Get the index of the i'th slot as it appears after mapping : SPO->POS : 0'th slot is S from POS so 2->0


fetchSlotIdx

public int fetchSlotIdx(int idx)
Get the index of the i'th slot as it appears from a mapping : for SPO->POS : 0'th slot is P so 1->0


map

public <T> Tuple<T> map(Tuple<T> src)
Apply to an unmapped tuple to get a tuple with the column mapping applied


unmap

public <T> Tuple<T> unmap(Tuple<T> src)
Apply to a mapped tuple to get a tuple with the column mapping reverse-applied


toString

public String toString()
Overrides:
toString in class Object

getLabel

public String getLabel()

mapName

public String mapName(String word)
Reorder the letters of a string by the same rules as this column map (forward, map direction)


unmapName

public String unmapName(String word)
Reorder the letters of a string by the same rules as this column map (backward, fetch direction)



Licenced under the Apache License, Version 2.0