Changeset 121
- Timestamp:
- 11/11/07 21:43:04 (10 months ago)
- Files:
-
- trunk/XJConf/DefinedTag.php (modified) (4 diffs)
- trunk/XJConf/DefinitionParser.php (modified) (4 diffs)
- trunk/XJConf/GenericTag.php (modified) (1 diff)
- trunk/XJConf/Tag.php (modified) (2 diffs)
- trunk/XJConf/XJConfFacade.php (modified) (7 diffs)
- trunk/XJConf/XmlParser.php (modified) (10 diffs)
- trunk/XJConf/converters/AutoPrimitiveValueConverter.php (modified) (1 diff)
- trunk/XJConf/converters/FactoryMethodValueConverter.php (modified) (4 diffs)
- trunk/XJConf/definitions/AbstractTagDefinition.php (modified) (3 diffs)
- trunk/XJConf/definitions/AttributeDefinition.php (modified) (6 diffs)
- trunk/XJConf/definitions/CDataDefinition.php (modified) (7 diffs)
- trunk/XJConf/definitions/ChildDefinition.php (modified) (3 diffs)
- trunk/XJConf/definitions/ConcreteTagDefinition.php (modified) (1 diff)
- trunk/XJConf/definitions/ConstructorDefinition.php (modified) (2 diffs)
- trunk/XJConf/definitions/Definition.php (modified) (2 diffs)
- trunk/XJConf/definitions/FactoryMethodDefinition.php (modified) (3 diffs)
- trunk/XJConf/definitions/MethodCallTagDefinition.php (modified) (4 diffs)
- trunk/XJConf/definitions/NamespaceDefinitions.php (modified) (1 diff)
- trunk/XJConf/definitions/handler/AttributeDefinitionHandler.php (modified) (1 diff)
- trunk/XJConf/definitions/handler/ChildDefinitionHandler.php (modified) (1 diff)
- trunk/XJConf/definitions/handler/FactoryMethodDefinitionHandler.php (modified) (1 diff)
- trunk/XJConf/definitions/handler/MethodCallTagDefinitionHandler.php (modified) (1 diff)
- trunk/XJConf/ext/Extension.php (modified) (1 diff)
- trunk/XJConf/ext/xinc/XInclude.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/XJConf/DefinedTag.php
r117 r121 7 7 */ 8 8 namespace net::xjconf; 9 use net::xjconf::Tag;10 9 use net::xjconf::definitions::Definition; 11 10 use net::xjconf::definitions::ConcreteTagDefinition; … … 18 17 class DefinedTag implements Tag 19 18 { 20 21 /** 22 * name of the tag 23 * 24 * @var string 25 */ 26 private $name = null; 27 28 /** 29 * character data 30 * 31 * @var string 32 */ 33 private $data = null; 34 35 /** 36 * content of the tag 37 * 38 * @var mixed 39 */ 40 private $content = null; 41 42 /** 43 * attributes of the tag 44 * 45 * @var array 46 */ 47 private $atts = array(); 48 49 /** 50 * Children of the tag 51 * 52 * @var array 53 */ 54 private $children = array(); 55 56 /** 57 * value of the tag 58 * 59 * @var TagDefinition 60 */ 61 private $tagDef = null; 62 63 /** 64 * Create a new tag without attributes 65 * 66 * @param name name of the tag 67 */ 68 public function __construct($name, $atts = array()) 69 { 70 $this->name = $name; 71 $this->atts = $atts; 72 } 73 74 /** 75 * Get the name of the tag 76 * 77 * @return name of the tag 78 */ 79 public function getName() 80 { 81 return $this->name; 82 } 83 84 /** 85 * Set the key 86 * 87 * @param string $key 88 */ 89 public function setKey($key) 90 { 91 $this->key = $key; 92 } 93 94 /** 95 * Get the key under which the value will be stored 96 * 97 * @return string 98 */ 99 public function getKey() 100 { 101 return $this->tagDef->getKey($this); 102 } 103 104 /** 105 * Add text data 106 * 107 * @param string $buf 108 * @return int new length of data 109 */ 110 public function addData($buf) 111 { 112 $this->data .= $buf; 113 return strlen($this->data); 114 } 115 116 /** 117 * Get the character data of the tag 118 * 119 * @return character data 120 */ 121 public function getData() 122 { 123 return $this->data; 124 } 125 126 /** 127 * Check, whether the tag has a certain attribute 128 * 129 * @param string $name 130 * @return boolean 131 */ 132 public function hasAttribute($name) 133 { 134 return isset($this->atts[$name]); 135 } 136 137 /** 138 * get an attribute 139 * 140 * @param string $name name of the attribute 141 * @return string value of the attribute 142 */ 143 public function getAttribute($name) 144 { 145 if ($this->hasAttribute($name) == true) { 146 return $this->atts[$name]; 147 } 148 149 return null; 150 } 151 152 /** 153 * get all attributes 154 * 155 * @return array 156 */ 157 public function getAttributes() 158 { 159 return $this->atts; 160 } 161 162 /** 19 /** 20 * name of the tag 21 * 22 * @var string 23 */ 24 private $name = null; 25 /** 26 * character data 27 * 28 * @var string 29 */ 30 private $data = null; 31 /** 32 * content of the tag 33 * 34 * @var mixed 35 */ 36 private $content = null; 37 /** 38 * attributes of the tag 39 * 40 * @var array 41 */ 42 private $atts = array(); 43 /** 44 * Children of the tag 45 * 46 * @var array 47 */ 48 private $children = array(); 49 /** 50 * value of the tag 51 * 52 * @var TagDefinition 53 */ 54 private $tagDef = null; 55 56 /** 57 * Create a new tag without attributes 58 * 59 * @param name name of the tag 60 */ 61 public function __construct($name, $atts = array()) 62 { 63 $this->name = $name; 64 $this->atts = $atts; 65 } 66 67 /** 68 * Get the name of the tag 69 * 70 * @return name of the tag 71 */ 72 public function getName() 73 { 74 return $this->name; 75 } 76 77 /** 78 * Set the key 79 * 80 * @param string $key 81 */ 82 public function setKey($key) 83 { 84 $this->key = $key; 85 } 86 87 /** 88 * Get the key under which the value will be stored 89 * 90 * @return string 91 */ 92 public function getKey() 93 { 94 return $this->tagDef->getKey($this); 95 } 96 97 /** 98 * Add text data 99 * 100 * @param string $buf 101 * @return int new length of data 102 */ 103 public function addData($buf) 104 { 105 $this->data .= $buf; 106 return strlen($this->data); 107 } 108 109 /** 110 * Get the character data of the tag 111 * 112 * @return character data 113 */ 114 public function getData() 115 { 116 return $this->data; 117 } 118 119 /** 120 * Check, whether the tag has a certain attribute 121 * 122 * @param string $name 123 * @return boolean 124 */ 125 public function hasAttribute($name) 126 { 127 return isset($this->atts[$name]); 128 } 129 130 /** 131 * get an attribute 132 * 133 * @param string $name name of the attribute 134 * @return string value of the attribute 135 */ 136 public function getAttribute($name) 137 { 138 if ($this->hasAttribute($name) === true) { 139 return $this->atts[$name]; 140 } 141 142 return null; 143 } 144 145 /** 146 * get all attributes 147 * 148 * @return array 149 */ 150 public function getAttributes() 151 { 152 return $this->atts; 153 } 154 155 /** 163 156 * Add a new child to this tag. 164 157 * … … 168 161 public function addChild(Tag $child) 169 162 { 170 array_push($this->children, $child);163 array_push($this->children, $child); 171 164 return count($this->children); 172 165 } 173 166 174 /**175 * Get the child with a specific name176 *177 * @param string $name178 * @return Tag179 */180 public function getChild($name)181 {182 foreach ($this->children as $child) {183 if ($child->getName()== $name) {184 return $child;185 }186 }187 188 return null;189 }190 191 /**192 * Get all children of the tag193 *194 * @return array195 */196 public function getChildren()197 {198 return $this->children;199 }200 201 /**167 /** 168 * Get the child with a specific name 169 * 170 * @param string $name 171 * @return Tag 172 */ 173 public function getChild($name) 174 { 175 foreach ($this->children as $child) { 176 if ($child->getName() === $name) { 177 return $child; 178 } 179 } 180 181 return null; 182 } 183 184 /** 185 * Get all children of the tag 186 * 187 * @return array 188 */ 189 public function getChildren() 190 { 191 return $this->children; 192 } 193 194 /** 202 195 * Set the content (overrides the character data) 203 196 * 204 197 * @param mixed $content 205 198 */ 206 public function setContent($content)207 {208 $this->content = $content;209 }210 211 /**212 * Get the content213 *214 * @return mixed215 */216 public function getContent()217 {218 if (null != $this->content) {219 return $this->content;220 }221 222 return $this->getData();223 }224 225 /**226 * Fetch the value227 *228 * @returnmixed the value of the tag229 */230 public function getConvertedValue()231 {232 return $this->tagDef->convertValue($this);233 }234 235 /**236 * Get the type of the value237 *238 * @param Tag $tag239 * @return string240 */241 public function getValueType(Tag $tag)242 {243 return $this->tagDef->getValueType($tag);244 }245 246 /**247 * Get the setter method248 *249 * @return string250 */199 public function setContent($content) 200 { 201 $this->content = $content; 202 } 203 204 /** 205 * Get the content 206 * 207 * @return mixed 208 */ 209 public function getContent() 210 { 211 if (null != $this->content) { 212 return $this->content; 213 } 214 215 return $this->getData(); 216 } 217 218 /** 219 * Fetch the value 220 * 221 * @return mixed the value of the tag 222 */ 223 public function getConvertedValue() 224 { 225 return $this->tagDef->convertValue($this); 226 } 227 228 /** 229 * Get the type of the value 230 * 231 * @param Tag $tag 232 * @return string 233 */ 234 public function getValueType(Tag $tag) 235 { 236 return $this->tagDef->getValueType($tag); 237 } 238 239 /** 240 * Get the setter method 241 * 242 * @return string 243 */ 251 244 public function getSetterMethod() 252 245 { 253 return $this->tagDef->getSetterMethod($this);254 } 255 256 /**257 * Checks, whether the tag supports indexed children258 *259 * @return boolean260 */261 public function supportsIndexedChildren()262 {263 return $this->tagDef->supportsIndexedChildren();264 }265 266 /**246 return $this->tagDef->getSetterMethod($this); 247 } 248 249 /** 250 * Checks, whether the tag supports indexed children 251 * 252 * @return boolean 253 */ 254 public function supportsIndexedChildren() 255 { 256 return $this->tagDef->supportsIndexedChildren(); 257 } 258 259 /** 267 260 * Set the tag definition object used for this tag 268 261 * … … 272 265 { 273 266 if ($tagDef instanceof ConcreteTagDefinition) { 274 $this->tagDef = $tagDef;267 $this->tagDef = $tagDef; 275 268 return; 276 269 } trunk/XJConf/DefinitionParser.php
r117 r121 164 164 private function initParser() 165 165 { 166 if (null == $this->reader) {166 if (null === $this->reader) { 167 167 $this->reader = new ::XMLReader(); 168 168 } … … 188 188 $attributes = array(); 189 189 $empty = $this->reader->isEmptyElement; 190 if ( TRUE== $this->reader->hasAttributes) {190 if (true === $this->reader->hasAttributes) { 191 191 // go to first attribute 192 192 $attribute = $this->reader->moveToFirstAttribute(); 193 193 // save data of all attributes 194 while ( TRUE== $attribute) {194 while (true === $attribute) { 195 195 $attributes[$this->reader->localName] = $this->reader->value; 196 196 $attribute = $this->reader->moveToNextAttribute(); … … 232 232 { 233 233 // a new namespace 234 if (self::TAG_NAMESPACE == $sName) {235 if (isset($atts['uri']) == false) {234 if (self::TAG_NAMESPACE === $sName) { 235 if (isset($atts['uri']) === false) { 236 236 throw new InvalidNamespaceDefinitionException('The <' . self::TAG_NAMESPACE . '> tag is missing the uri attribute.'); 237 237 } … … 265 265 { 266 266 // namespace definition ends, switch back to default namespace 267 if (self::TAG_NAMESPACE == $sName) {267 if (self::TAG_NAMESPACE === $sName) { 268 268 $this->currentNamespace = self::DEFAULT_NAMESPACE; 269 269 return; trunk/XJConf/GenericTag.php
r115 r121 15 15 class GenericTag implements Tag 16 16 { 17 /**18 * name of the tag19 *20 * @var string21 */22 private $name = null;23 /**24 * character data25 *26 * @var string27 */28 private $data = null;29 /**30 * content of the tag (overrides data)31 *32 * @var mixed33 */34 private $content = null;35 /**36 * attributes of the tag37 *38 * @var array39 */40 private $atts = array();41 /**42 * Children of the tag43 *44 * @var array45 */46 private $children = array();47 /**48 * value of the tag49 *50 * @var mixed51 */52 private $value = null;53 /**54 * Key of the tag55 *56 * @var string57 */58 private $key = null;59 60 /**61 * Create a new tag with or without attributes62 *63 * @param string $name name of the tag64 * @param array $atts optional list of attributes65 */66 public function __construct($name, $atts = array())67 {68 $this->name = $name;69 $this->atts = $atts;70 }71 72 /**73 * Get the name of the tag74 *75 * @return string76 */77 public function getName()78 {79 return $this->name;80 }81 82 /**83 * Set the key84 *85 * @param string $key86 */87 public function setKey($key)88 {89 $this->key = $key;90 }91 92 /**93 * Get the key under which the value will be stored94 *95 * @return string96 */97 public function getKey()98 {99 return $this->key;100 }101 102 /**103 * Add text data104 *105 * @param string $buf106 * @return int new length of data107 */108 public function addData($buf)109 {110 $this->data .= $buf;111 return strlen($this->data);112 }113 114 /**115 * Get the character data of the tag116 *117 * @return string118 */119 public function getData()120 {121 return $this->data;122 }123 124 /**125 * Check, whether the tag has a certain attribute126 *127 * @param string $name128 * @return boolean129 */130 public function hasAttribute($name)131 {132 return isset($this->atts[$name]);133 }134 135 /**136 * get an attribute137 *138 * @param string $name name of the attribute139 * @return string value of the attribute140 */141 public function getAttribute($name)142 {143 if ($this->hasAttribute($name)== true) {144 return $this->atts[$name];145 }146 147 return null;148 }149 150 /**151 * get all attributes152 *153 * @return array154 */155 public function getAttributes()156 {157 return $this->atts;158 }159 160 /**161 * Add a new child to this tag.162 *163 * @param Tag $child child to add164 * @return int number of childs added165 */166 public function addChild(Tag $child)167 {168 array_push($this->children, $child);169 return count($this->children);170 }171 172 /**173 * Get the child with a specific name174 *175 * @param string $name176 * @return Tag177 */178 public function getChild($name)179 {180 foreach ($this->children as $child) {181 if ($child->getName()== $name) {182 return $child;183 }184 }185 186 return null;187 }188 189 /**190 * Get all children of the tag191 *192 * @return array193 */194 public function getChildren()195 {196 return $this->children;197 }198 199 /**17 /** 18 * name of the tag 19 * 20 * @var string 21 */ 22 private $name = null; 23 /** 24 * character data 25 * 26 * @var string 27 */ 28 private $data = null; 29 /** 30 * content of the tag (overrides data) 31 * 32 * @var mixed 33 */ 34 private $content = null; 35 /** 36 * attributes of the tag 37 * 38 * @var array 39 */ 40 private $atts = array(); 41 /** 42 * Children of the tag 43 * 44 * @var array 45 */ 46 private $children = array(); 47 /** 48 * value of the tag 49 * 50 * @var mixed 51 */ 52 private $value = null; 53 /** 54 * Key of the tag 55 * 56 * @var string 57 */ 58 private $key = null; 59 60 /** 61 * Create a new tag with or without attributes 62 * 63 * @param string $name name of the tag 64 * @param array $atts optional list of attributes 65 */ 66 public function __construct($name, $atts = array()) 67 { 68 $this->name = $name; 69 $this->atts = $atts; 70 } 71 72 /** 73 * Get the name of the tag 74 * 75 * @return string 76 */ 77 public function getName() 78 { 79 return $this->name; 80 } 81 82 /** 83 * Set the key 84 * 85 * @param string $key 86 */ 87 public function setKey($key) 88 { 89 $this->key = $key; 90 } 91 92 /** 93 * Get the key under which the value will be stored 94 * 95 * @return string 96 */ 97 public function getKey() 98 { 99 return $this->key; 100 } 101 102 /** 103 * Add text data 104 * 105 * @param string $buf 106 * @return int new length of data 107 */ 108 public function addData($buf) 109 { 110 $this->data .= $buf; 111 return strlen($this->data); 112 } 113 114 /** 115 * Get the character data of the tag 116 * 117 * @return string 118 */ 119 public function getData() 120 { 121 return $this->data; 122 } 123 124 /** 125 * Check, whether the tag has a certain attribute 126 * 127 * @param string $name 128 * @return boolean 129 */ 130 public function hasAttribute($name) 131 { 132 return isset($this->atts[$name]); 133 } 134 135 /** 136 * get an attribute 137 * 138 * @param string $name name of the attribute 139 * @return string value of the attribute 140 */ 141 public function getAttribute($name) 142 { 143 if ($this->hasAttribute($name) === true) { 144 return $this->atts[$name]; 145 } 146 147 return null; 148 } 149 150 /** 151 * get all attributes 152 * 153 * @return array 154 */ 155 public function getAttributes() 156 { 157 return $this->atts; 158 } 159 160 /** 161 * Add a new child to this tag. 162 * 163 * @param Tag $child child to add 164 * @return int number of childs added 165 */ 166 public function addChild(Tag $child) 167 { 168 array_push($this->children, $child); 169 return count($this->children); 170 } 171 172 /** 173 * Get the child with a specific name 174 * 175 * @param string $name 176 * @return Tag 177 */ 178 public function getChild($name) 179 { 180 foreach ($this->children as $child) { 181 if ($child->getName() === $name) { 182 return $child; 183 } 184 } 185 186 return null; 187 } 188 189 /** 190 * Get all children of the tag 191 * 192 * @return array 193 */ 194 public function getChildren() 195 { 196 return $this->children; 197 } 198 199 /** 200 200 * Set the content (overrides the character data) 201 201 * 202 202 * @param mixed $content 203 203 */ 204 public function setContent($content)205 {206 $this->content = $content;207 }208 209 /**210 * Get the content211 *212 * @return mixed213 */214 public function getContent()215 {216 if (null != $this->content) {217 return $this->content;218 }219 220 return $this->getData();221 }222 223 /**224 * Fetch the value225 *226 * @returnmixed the value of the tag227 */228 public function getConvertedValue()229 {230 return $this->value;231 }232 233 /**234 * Get the type of the value235 *236 * @return string237 */238 public function getValueType(Tag $tag)239 {240 if (null== $this->value) {241 return null;242 }243 244 if (is_object($this->value) == true) {204 public function setContent($content) 205 { 206 $this->content = $content; 207 } 208 209 /** 210 * Get the content 211 * 212 * @return mixed 213 */ 214 public function getContent() 215 { 216 if (null !== $this->content) { 217 return $this->content; 218 } 219 220 return $this->getData(); 221 } 222 223 /** 224 * Fetch the value 225 * 226 * @return mixed the value of the tag 227 */ 228 public function getConvertedValue() 229 { 230 return $this->value; 231 } 232 233 /** 234 * Get the type of the value 235 * 236 * @return string 237 */ 238 public function getValueType(Tag $tag) 239 { 240 if (null === $this->value) { 241 return null; 242 } 243 244 if (is_object($this->value) == true) { 245 245 return get_class($this->value); 246 }247 248 return gettype($this->value);249 }250 251 /**252 * Get the setter method253 */246 } 247 248 return gettype($this->value); 249 } 250 251 /** 252 * Get the setter method 253 */ 254 254 public function getSetterMethod() 255 255 { 256 if (null == $this->key) { 257 return null; 258 } 259 return 'set' . ucfirst($this->key); 260 } 261 262 /** 263 * Checks, whether the tag supports indexed children 264 * 265 * @return boolean 266 */ 267 public function supportsIndexedChildren() 268 { 269 return true; 270 } 271 272 /** 273 * Set the value of the tag 274 * 275 * @param mixed 276 */ 277 public function setValue($value) 278 { 279 $this->value = $value; 280 } 281 282 public function getDefinition() { 283 return null; 284 } 256 if (null === $this->key) { 257 return null; 258 } 259 260 return 'set' . ucfirst($this->key); 261 } 262 263 /** 264 * Checks, whether the tag supports indexed children 265 * 266 * @return boolean 267 */ 268 public function supportsIndexedChildren() 269 { 270 return true; 271 } 272 273 /** 274 * Set the value of the tag 275 * 276 * @param mixed 277 */ 278 public function setValue($value) 279 { 280 $this->value = $value; 281 } 282 283 /** 284 * returns the definition for this tag 285 * 286 * @return Definition 287 */ 288 public function getDefinition() 289 { 290 return null; 291 } 285 292 } 286 293 ?> trunk/XJConf/Tag.php
r115 r121 15 15 { 16 16 /** 17 * Get the name of the tag18 *19 * @return name of the tag20 */21 public function getName();17 * Get the name of the tag 18 * 19 * @return name of the tag 20 */ 21 public function getName(); 22 22 23 /**24 * Get the key under which the value will be stored25 *26 *
