com.oxygenxml.validate.nvdl
Class FilteredAttributes

java.lang.Object
  extended by com.oxygenxml.validate.nvdl.FilteredAttributes
All Implemented Interfaces:
Attributes

 class FilteredAttributes
extends Object
implements Attributes

Implementation of the Attributes interface that filters out some of the attributes of an actual Attributes implementation. We will keep only the attributes whose indexes are specified in a given set of indexes.


Field Summary
private  Attributes attributes
          The actual attributes, we will filter out some of them.
private  IntSet indexSet
          The set of indexes of the attributes to used.
private  int[] reverseIndexMap
          Maps indexes in the real attributes list to 1 based indexes in the filtered attributes list.
 
Constructor Summary
FilteredAttributes(IntSet indexSet, Attributes attributes)
          Creates a filtered attributes instance.
 
Method Summary
 int getIndex(String qName)
           
 int getIndex(String uri, String localName)
           
 int getLength()
          The number of attributes, the same as the length of the list of indexes.
 String getLocalName(int index)
          Get the local name for the index-th attribute.
 String getQName(int index)
          Get the QName for the index-th attribute.
private  int getRealIndex(String qName)
          Get the real index, in the initial attributes list of a given attribute.
private  int getRealIndex(String uri, String localName)
          Get the real index, in the initial attributes list of a given attribute.
 String getType(int index)
          Get the type for the index-th attribute.
 String getType(String qName)
          Get the type of the attribute.
 String getType(String uri, String localName)
          Get the type of the attribute.
 String getURI(int index)
          Get the URI for the index-th attribute.
 String getValue(int index)
          Get the value for the index-th attribute.
 String getValue(String qName)
          Get the value of the attribute.
 String getValue(String uri, String localName)
          Get the value of the attribute.
private  int reverseIndex(int k)
          Gets the index in the filtered set for a given real index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributes

private final Attributes attributes
The actual attributes, we will filter out some of them.


indexSet

private final IntSet indexSet
The set of indexes of the attributes to used.


reverseIndexMap

private int[] reverseIndexMap
Maps indexes in the real attributes list to 1 based indexes in the filtered attributes list. For instance if we keep only the 1st and the 3rd attributes from 4 attributes then the reverse index map will have as values [0] --> 1 [1] --> 0 [2] --> 2 [3] --> 0

Constructor Detail

FilteredAttributes

public FilteredAttributes(IntSet indexSet,
                          Attributes attributes)
Creates a filtered attributes instance.

Parameters:
indexSet - The set with indexes that we will keep.
attributes - The actual attributes.
Method Detail

reverseIndex

private int reverseIndex(int k)
Gets the index in the filtered set for a given real index. If the reverseIndexMap is not computed it computes it, otherwise it just uses the previously computed map.

Parameters:
k - The index in the real attributes.
Returns:
The index in the filtered attributes.

getLength

public int getLength()
The number of attributes, the same as the length of the list of indexes.

Specified by:
getLength in interface Attributes

getURI

public String getURI(int index)
Get the URI for the index-th attribute.

Specified by:
getURI in interface Attributes

getLocalName

public String getLocalName(int index)
Get the local name for the index-th attribute.

Specified by:
getLocalName in interface Attributes

getQName

public String getQName(int index)
Get the QName for the index-th attribute.

Specified by:
getQName in interface Attributes

getType

public String getType(int index)
Get the type for the index-th attribute.

Specified by:
getType in interface Attributes

getValue

public String getValue(int index)
Get the value for the index-th attribute.

Specified by:
getValue in interface Attributes

getIndex

public int getIndex(String uri,
                    String localName)
Specified by:
getIndex in interface Attributes

getIndex

public int getIndex(String qName)
Specified by:
getIndex in interface Attributes

getRealIndex

private int getRealIndex(String uri,
                         String localName)
Get the real index, in the initial attributes list of a given attribute. If the attribute is filtered out then return -1.

Parameters:
uri - The attribute uri.
localName - The attribute local name.
Returns:
The real index if the attribute is present and not filtered out, otherwise -1.

getRealIndex

private int getRealIndex(String qName)
Get the real index, in the initial attributes list of a given attribute. If the attribute is filtered out then return -1.

Parameters:
qName - The attribute qualified name.
Returns:
The real index if the attribute is present and not filtered out, otherwise -1.

getType

public String getType(String uri,
                      String localName)
Get the type of the attribute.

Specified by:
getType in interface Attributes
Parameters:
uri - The attribute uri.
localName - The attribute local name.

getValue

public String getValue(String uri,
                       String localName)
Get the value of the attribute.

Specified by:
getValue in interface Attributes
Parameters:
uri - The attribute uri.
localName - The attribute local name.

getType

public String getType(String qName)
Get the type of the attribute.

Specified by:
getType in interface Attributes
Parameters:
qName - The attribute qualified name.

getValue

public String getValue(String qName)
Get the value of the attribute.

Specified by:
getValue in interface Attributes
Parameters:
qName - The attribute qualified name.