예제 #1
0
 public function getObject(Spring\Object\Parser $parser, \SimpleXMLElement $element)
 {
     $object = new Common\Mutable\HashSet();
     $children = $parser->getElementChildren($element, null);
     foreach ($children as $child) {
         $object->putValue($parser->getObjectFromElement($child));
     }
     return $object;
 }
예제 #2
0
 /**
  * This method parses a "set" node.
  *
  * @access protected
  * @param \SimpleXMLElement $root                           a reference to the root node
  * @param \SimpleXMLElement $node                           a reference to the "set" node
  * @return Common\Mutable\ISet                              a set of values
  * @throws Throwable\Parse\Exception                        indicates that problem occurred while
  *                                                          parsing
  */
 protected function parseSetElement(\SimpleXMLElement $root, \SimpleXMLElement $node)
 {
     $set = new Common\Mutable\HashSet();
     $children = $node->children();
     foreach ($children as $child) {
         $name = $child->getName();
         switch ($name) {
             case 'array':
                 $set->putValue($this->parseArrayElement($root, $child));
                 break;
             case 'dictionary':
                 $set->putValue($this->parseDictionaryElement($root, $child));
                 break;
             case 'expression':
                 $set->putValue($this->parseExpressionElement($root, $child));
                 break;
             case 'idref':
                 $set->putValue($this->parseIdRefElement($root, $child));
                 break;
             case 'list':
                 $set->putValue($this->parseListElement($root, $child));
                 break;
             case 'map':
                 $set->putValue($this->parseMapElement($root, $child));
                 break;
             case 'null':
                 $set->putValue($this->parseNullElement($root, $child));
                 break;
             case 'object':
                 $set->putValue($this->parseInnerObjectElement($root, $child));
                 break;
             case 'ref':
                 $set->putValue($this->parseRefElement($root, $child));
                 break;
             case 'set':
                 $set->putValue($this->parseSetElement($root, $child));
                 break;
             case 'undefined':
                 $set->putValue($this->parseUndefinedElement($root, $child));
                 break;
             case 'value':
                 $set->putValue($this->parseValueElement($root, $child));
                 break;
             default:
                 throw new Throwable\Parse\Exception('Unable to process Spring XML. Tag ":tag" has invalid child node ":child".', array(':tag' => 'set', ':child' => $name));
                 break;
         }
     }
     return $set;
 }
예제 #3
0
파일: Set.php 프로젝트: bluesnowman/Chimera
 /**
  * This method returns the power set of the specified set.
  *
  * @access public
  * @static
  * @param Common\ISet $set                                  the hash set to be used
  * @return Common\ISet                                      the power set
  *
  * @see http://rosettacode.org/wiki/Power_Set
  */
 public static function powerset(Common\ISet $set)
 {
     $powerset = new Common\Mutable\HashSet();
     $powerset->putValue(new Common\Mutable\HashSet());
     foreach ($set as $element) {
         $hashset = new Common\Mutable\HashSet();
         foreach ($powerset as $subset) {
             $hashset->putValue($subset);
             $temp = new Common\Mutable\HashSet($subset);
             $temp->putValue($element);
             $hashset->putValue($temp);
         }
         $powerset = $hashset;
     }
     return $powerset;
 }