// file: $isip/class/mmedia/xt_05.cc
// version: $Id: xt_05.cc 9929 2004-12-31 02:42:05Z duncan $

#include "XMLToken.h"

// method: setDepth
//
// arguments:
//   short int depth: (input) the depth to assign
//     to the token
//
// return: a boolean indicating status
//
boolean XMLToken::setDepth(short int depth_a) {
  
  // prevent depths below 0
  //
  if(depth_a < 0) {
    return false;
  }
  else {
    depth_d = depth_a;
  }
  
  // indicate success
  //
  return true;
}

// method: isA
//
// arguments:
//   XMLToken::Type type: (input) an xml token type
//
// returns: a boolean indicating status
//
// this method compares type_a against this
// token's type
//
boolean XMLToken::isA(XMLToken::TYPE type_a) {
  return (getType() == type_a);
}

// method: isA
//
// arguments:
//   String value: (input) an xml token value
//
// returns: a boolean indicating status
//
// this method compares the value of an XMLToken
// against this token's value
//
boolean XMLToken::isA(String value_a) {
  return (getValue().eq(value_a));
}

// method: isA
//
// arguments:
//   XMLToken::Type type: (input) an xml token type
//   String value: (input) an xml token value
//
// returns: a boolean indicating status
//
// this method checks the type and value of an XMLToken
// against this token's type and value
//
boolean XMLToken::isA(String value_a, XMLToken::TYPE type_a) {
  return (isA(value_a) && isA(type_a));
}

// method: init
//
// arguments:
//   TYPE type: (input) the type to assign to the token
//   String value: (input) the value to assign to the token
//   Vector< Pair<String, String> > attrib_array: (input)
//     a vector of attribute/value pairs
//   Integral::CMODE ctype: (input) the clear type to use
//     on the token
//   long token_depth: the depth to assign to the token
//
// return: a boolean indicating status
//
// this method initializes the token
//
boolean XMLToken::init(TYPE type_a,
		       String value_a,
		       Vector< Pair<String, String> > attrib_array_a,
		       long token_depth_a,
		       Integral::CMODE ctype_a) {
  
  clear(ctype_a);
  setType(type_a);
  setValue(value_a);
  setAttributes(attrib_array_a);
  setDepth(token_depth_a);
  
  return true;
}

// method: init
//
// arguments:
//   TYPE type: (input) the type to assign to the token
//   String value: (input) the value to assign to the token
//   Integral::CMODE ctype: (input) the clear type to use
//     on the token
//   long token_depth: the depth to assign to the token
//
// return: a boolean indicating status
//
// this method initializes the token, with no attributes
//
boolean XMLToken::init(TYPE type_a,
		       String value_a,
		       long token_depth_a,
		       Integral::CMODE ctype_a) {
  
  clear(ctype_a);
  setType(type_a);
  setValue(value_a);
  setDepth(token_depth_a);
  
  return true;
}

// method: init
//
// arguments:
//   TYPE type: (input) the type to assign to the token
//   String value: (input) the value to assign to the token
//   byte** attrib_array: (input)
//     a 2D array of attribute/value pairs
//   Integral::CMODE ctype: (input) the clear type to use
//     on the token
//   long token_depth: (input) the depth to assign to the token
//
// return: a boolean indicating status
//
// this method initializes the token
//
boolean XMLToken::init(TYPE type_a,
		       String value_a,
		       const byte** attrib_array_a,
		       long token_depth_a,
		       Integral::CMODE ctype_a) {
  
  
  clear(ctype_a);
  setType(type_a);
  setValue(value_a);
  setAttributes(attrib_array_a);
  setDepth(token_depth_a);
  
  return true;
}
