ACEXML_AttributesImpl Class Reference

ACEXML_AttributesImpl provides the default implementation of interface ACEXML_Attributes. More...

#include <ACEXML/common/AttributesImpl.h>

Inheritance diagram for ACEXML_AttributesImpl:

Inheritance graph
[legend]
Collaboration diagram for ACEXML_AttributesImpl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACEXML_AttributesImpl (int size=ACEXML_AttributesImpl_Default_Size)
 ACEXML_AttributesImpl (const ACEXML_AttributesImpl &attrs)
virtual ~ACEXML_AttributesImpl (void)
virtual int addAttribute (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value)
virtual int addAttribute (const ACEXML_Attribute &att)
virtual int isDuplicate (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName)
virtual int removeAttribute (size_t index)
virtual int getIndex (const ACEXML_Char *qName)
virtual int getIndex (const ACEXML_Char *uri, const ACEXML_Char *localPart)
virtual size_t getLength (void)
virtual const ACEXML_ChargetLocalName (size_t index)
virtual const ACEXML_ChargetQName (size_t index)
virtual const ACEXML_ChargetType (size_t index)
virtual const ACEXML_ChargetType (const ACEXML_Char *qName)
virtual const ACEXML_ChargetType (const ACEXML_Char *uri, const ACEXML_Char *localPart)
virtual const ACEXML_ChargetURI (size_t index)
virtual const ACEXML_ChargetValue (size_t index)
virtual const ACEXML_ChargetValue (const ACEXML_Char *qName)
virtual const ACEXML_ChargetValue (const ACEXML_Char *uri, const ACEXML_Char *localPart)
virtual int setAttribute (size_t index, const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value)
virtual int setLocalName (size_t index, const ACEXML_Char *localName)
virtual int setQName (size_t index, const ACEXML_Char *qName)
virtual int setURI (size_t index, const ACEXML_Char *uri)
virtual int setType (size_t index, const ACEXML_Char *type)
virtual int setValue (size_t index, const ACEXML_Char *value)

Private Attributes

ACEXML_Attribute_Array attrs_
 Container for all attributes.


Detailed Description

ACEXML_AttributesImpl provides the default implementation of interface ACEXML_Attributes.

This class provides a default implementation of the SAX2 Attributes interface, with the addition of manipulators so that the list can be modified or reused.

There are two typical uses of this class:

This class replaces the now-deprecated SAX1 AttributeListImpl class; in addition to supporting the updated Attributes interface rather than the deprecated AttributeList interface, it also includes a much more efficient implementation using a single array rather than a set of Vectors.

See also:
ACEXML_Attributes

Definition at line 143 of file AttributesImpl.h.


Constructor & Destructor Documentation

ACEXML_AttributesImpl::ACEXML_AttributesImpl int  size = ACEXML_AttributesImpl_Default_Size  ) 
 

Initialize an AttributesImpl that holds attributes.

Definition at line 9 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00010   : attrs_ (size)
00011 {
00012   this->attrs_.size (0);        // attrs array contains nothing
00013 }

ACEXML_AttributesImpl::ACEXML_AttributesImpl const ACEXML_AttributesImpl attrs  ) 
 

Definition at line 15 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00017   : ACEXML_Attributes (attrs),
00018     attrs_ (attrs.attrs_.size ())
00019 {
00020   for (size_t i = 0; i < attrs.attrs_.size (); i++)
00021     this->attrs_[i] = attrs.attrs_[i];
00022 }

ACEXML_AttributesImpl::~ACEXML_AttributesImpl void   )  [virtual]
 

Definition at line 24 of file AttributesImpl.cpp.

00025 {
00026 }


Member Function Documentation

int ACEXML_AttributesImpl::addAttribute const ACEXML_Attribute att  )  [virtual]
 

Definition at line 49 of file AttributesImpl.cpp.

References attrs_, isDuplicate(), ACEXML_Attribute::localName(), ACEXML_Attribute::qName(), ACE_Array_Base< T >::size(), and ACEXML_Attribute::uri().

00050 {
00051   if (this->isDuplicate (att.uri(), att.localName(), att.qName()))
00052     return -1;
00053   size_t length = this->attrs_.size ();
00054   this->attrs_.size (length+1);
00055   this->attrs_[length] = att;
00056   return static_cast<int> (length);
00057 }

int ACEXML_AttributesImpl::addAttribute const ACEXML_Char uri,
const ACEXML_Char localName,
const ACEXML_Char qName,
const ACEXML_Char type,
const ACEXML_Char value
[virtual]
 

Add a new attribute using the argument(s) supplied. Return -1 if an attribute with the same name already exists.

Definition at line 29 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, isDuplicate(), setAttribute(), and ACE_Array_Base< T >::size().

Referenced by ACEXML_Parser::parse_element().

00034 {
00035   if (this->isDuplicate (uri, localName, qName))
00036     return -1;
00037   size_t length = this->attrs_.size ();
00038   this->attrs_.size (length+1);
00039   this->setAttribute (length,
00040                       uri,
00041                       localName,
00042                       qName,
00043                       type,
00044                       value);
00045   return static_cast<int> (length);
00046 }

int ACEXML_AttributesImpl::getIndex const ACEXML_Char uri,
const ACEXML_Char localPart
[virtual]
 

Look up the index of an attribute by Namespace name. Return -1 if we fail to find a match.

Implements ACEXML_Attributes.

Definition at line 106 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, ACE_Array_Base< T >::size(), and ACE_OS::strcmp().

00108 {
00109   for (size_t i = 0; i < this->attrs_.size (); i++)
00110     if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
00111         ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
00112       return static_cast<int> (i);
00113 
00114   return -1;
00115 }

int ACEXML_AttributesImpl::getIndex const ACEXML_Char qName  )  [virtual]
 

Look up the index of an attribute by XML 1.0 qualified name. Return -1 if we fail to find a match.

Implements ACEXML_Attributes.

Definition at line 96 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, ACE_Array_Base< T >::size(), and ACE_OS::strcmp().

00097 {
00098   for (size_t i = 0; i < this->attrs_.size (); i++)
00099     if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
00100       return static_cast<int> (i);
00101 
00102   return -1;
00103 }

size_t ACEXML_AttributesImpl::getLength void   )  [virtual]
 

Return the number of attributes in the list.

Implements ACEXML_Attributes.

Definition at line 118 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00119 {
00120   return this->attrs_.size ();
00121 }

const ACEXML_Char * ACEXML_AttributesImpl::getLocalName size_t  index  )  [virtual]
 

Look up an attribute's local name by index. Return 0 if index is out of range.

Implements ACEXML_Attributes.

Definition at line 124 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00125 {
00126   if (index < this->attrs_.size ())
00127     return this->attrs_[index].localName ();
00128   return 0;
00129 }

const ACEXML_Char * ACEXML_AttributesImpl::getQName size_t  index  )  [virtual]
 

Look up an attribute's XML 1.0 qualified name by index. Return 0 if index is out of range.

Implements ACEXML_Attributes.

Definition at line 133 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00134 {
00135   if (index < this->attrs_.size ())
00136     return this->attrs_[index].qName ();
00137   return 0;
00138 }

const ACEXML_Char * ACEXML_AttributesImpl::getType const ACEXML_Char uri,
const ACEXML_Char localPart
[virtual]
 

Look up an attribute's type by Namespace name. Return 0 if we fail to find a match.

Implements ACEXML_Attributes.

Definition at line 160 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, ACE_Array_Base< T >::size(), and ACE_OS::strcmp().

00162 {
00163   for (size_t i = 0; i < this->attrs_.size (); i++)
00164     if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
00165         ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
00166       return this->attrs_[i].type ();
00167 
00168   return 0;
00169 }

const ACEXML_Char * ACEXML_AttributesImpl::getType const ACEXML_Char qName  )  [virtual]
 

Look up an attribute's type by XML 1.0 qualified name. Return 0 if we fail to find a match.

Implements ACEXML_Attributes.

Definition at line 150 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, ACE_Array_Base< T >::size(), and ACE_OS::strcmp().

00151 {
00152   for (size_t i = 0; i < this->attrs_.size (); i++)
00153     if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
00154       return this->attrs_[i].type ();
00155 
00156   return 0;
00157 }

const ACEXML_Char * ACEXML_AttributesImpl::getType size_t  index  )  [virtual]
 

Look up an attribute's type by index. Return 0 if index is out of range.

Implements ACEXML_Attributes.

Definition at line 141 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00142 {
00143   if (index < this->attrs_.size ())
00144     return this->attrs_[index].type ();
00145   return 0;
00146 }

const ACEXML_Char * ACEXML_AttributesImpl::getURI size_t  index  )  [virtual]
 

Look up an attribute's Namespace URI by index. Return 0 if index is out of range.

Implements ACEXML_Attributes.

Definition at line 173 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00174 {
00175   if (index < this->attrs_.size ())
00176     return this->attrs_[index].uri ();
00177   return 0;
00178 }

const ACEXML_Char * ACEXML_AttributesImpl::getValue const ACEXML_Char uri,
const ACEXML_Char localPart
[virtual]
 

Look up an attribute's value by Namespace name. Return 0 if we fail to find a match.

Implements ACEXML_Attributes.

Definition at line 200 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, ACE_Array_Base< T >::size(), and ACE_OS::strcmp().

00202 {
00203   for (size_t i = 0; i < this->attrs_.size (); i++)
00204     if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
00205         ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
00206       return this->attrs_[i].value ();
00207 
00208   return 0;
00209 }

const ACEXML_Char * ACEXML_AttributesImpl::getValue const ACEXML_Char qName  )  [virtual]
 

Look up an attribute's value by XML 1.0 qualified name. Return 0 if we fail to find a match.

Implements ACEXML_Attributes.

Definition at line 190 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, ACE_Array_Base< T >::size(), and ACE_OS::strcmp().

00191 {
00192   for (size_t i = 0; i < this->attrs_.size (); i++)
00193     if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
00194       return this->attrs_[i].value ();
00195 
00196   return 0;
00197 }

const ACEXML_Char * ACEXML_AttributesImpl::getValue size_t  index  )  [virtual]
 

Look up an attribute's value by index. Return 0 if index is out of range.

Implements ACEXML_Attributes.

Definition at line 182 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00183 {
00184   if (index < this->attrs_.size ())
00185     return this->attrs_[index].value ();
00186   return 0;
00187 }

int ACEXML_AttributesImpl::isDuplicate const ACEXML_Char uri,
const ACEXML_Char localName,
const ACEXML_Char qName
[virtual]
 

Check for duplicate attributes.

Definition at line 60 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, ACE_Array_Base< T >::size(), and ACE_OS::strcmp().

Referenced by addAttribute().

00063 {
00064   for (size_t i = 0; i < this->attrs_.size(); ++i)
00065     {
00066       if (ACE_OS::strcmp (this->attrs_[i].localName(), localName) == 0)
00067         {
00068           if (qName != 0 && this->attrs_[i].qName() != 0
00069               && ACE_OS::strcmp (this->attrs_[i].qName(), qName) == 0)
00070             {
00071               if (uri != 0 && this->attrs_[i].uri() != 0
00072                   && ACE_OS::strcmp (this->attrs_[i].uri(), uri) == 0)
00073                 return 1;
00074             }
00075         }
00076     }
00077   return 0;
00078 }

int ACEXML_AttributesImpl::removeAttribute size_t  index  )  [virtual]
 

Remove an attribute from the array. Notice that this operation can invalidate previously acquired value. (It will repack the array.)

Definition at line 81 of file AttributesImpl.cpp.

References attrs_, and ACE_Array_Base< T >::size().

00082 {
00083   size_t length = this->attrs_.size ();
00084 
00085   if (index >= length)
00086     return -1;
00087 
00088   this->attrs_[index] = this->attrs_[length - 1];
00089   this->attrs_.size (length - 1);
00090 
00091   return 0;
00092 }

int ACEXML_AttributesImpl::setAttribute size_t  index,
const ACEXML_Char uri,
const ACEXML_Char localName,
const ACEXML_Char qName,
const ACEXML_Char type,
const ACEXML_Char value
[virtual]
 

Set an attribute at index. Return -1 if index is out of range.

Definition at line 212 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, and ACE_Array_Base< T >::size().

Referenced by addAttribute().

00218 {
00219   if (index < this->attrs_.size ())
00220     {
00221       this->attrs_[index].setAttribute (uri,
00222                                         localName,
00223                                         qName,
00224                                         type,
00225                                         value);
00226       return 0;
00227     }
00228 
00229   return -1;
00230 }

int ACEXML_AttributesImpl::setLocalName size_t  index,
const ACEXML_Char localName
[virtual]
 

Set the localName of the attribute at . return -1 if is out of range.

Definition at line 234 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, and ACE_Array_Base< T >::size().

00236 {
00237   if (index < this->attrs_.size ())
00238     {
00239       this->attrs_[index].localName (localName);
00240       return 0;
00241     }
00242   return -1;
00243 }

int ACEXML_AttributesImpl::setQName size_t  index,
const ACEXML_Char qName
[virtual]
 

Set the qName of the attribute at . return -1 if is out of range.

Definition at line 246 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, and ACE_Array_Base< T >::size().

00248 {
00249   if (index < this->attrs_.size ())
00250     {
00251       this->attrs_[index].qName (qName);
00252       return 0;
00253     }
00254   return -1;
00255 }

int ACEXML_AttributesImpl::setType size_t  index,
const ACEXML_Char type
[virtual]
 

Set the type of the attribute at . return -1 if is out of range.

Definition at line 271 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, and ACE_Array_Base< T >::size().

00273 {
00274   if (index < this->attrs_.size ())
00275     {
00276       this->attrs_[index].type (type);
00277       return 0;
00278     }
00279   return -1;
00280 }

int ACEXML_AttributesImpl::setURI size_t  index,
const ACEXML_Char uri
[virtual]
 

Set the URI of the attribute at . return -1 if is out of range.

Definition at line 259 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, and ACE_Array_Base< T >::size().

00261 {
00262   if (index < this->attrs_.size ())
00263     {
00264       this->attrs_[index].uri (uri);
00265       return 0;
00266     }
00267   return -1;
00268 }

int ACEXML_AttributesImpl::setValue size_t  index,
const ACEXML_Char value
[virtual]
 

Set the value of the attribute at . return -1 if is out of range.

Definition at line 283 of file AttributesImpl.cpp.

References ACEXML_Char, attrs_, and ACE_Array_Base< T >::size().

00285 {
00286   if (index < this->attrs_.size ())
00287     {
00288       this->attrs_[index].value (value);
00289       return 0;
00290     }
00291   return -1;
00292 }


Member Data Documentation

ACEXML_Attribute_Array ACEXML_AttributesImpl::attrs_ [private]
 

Container for all attributes.

Definition at line 300 of file AttributesImpl.h.

Referenced by ACEXML_AttributesImpl(), addAttribute(), getIndex(), getLength(), getLocalName(), getQName(), getType(), getURI(), getValue(), isDuplicate(), removeAttribute(), setAttribute(), setLocalName(), setQName(), setType(), setURI(), and setValue().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:47:43 2006 for ACEXML by doxygen 1.3.6