From d9f864a13f9216b7ee78a85c53d3184220eb01c3 Mon Sep 17 00:00:00 2001 From: Silvio Date: Thu, 15 Jul 2010 18:15:21 -0300 Subject: Moving iterators to their own folder --- classes/IsisFieldIterator.php | 79 ---------------------- classes/IsisMethodIterator.php | 63 ----------------- classes/IsisNormalSubfieldFilterIterator.php | 14 ---- classes/IsisRowIterator.php | 58 ---------------- classes/IsisSubfieldIterator.php | 75 -------------------- classes/IsisValueIterator.php | 62 ----------------- classes/iterators/IsisFieldIterator.php | 79 ++++++++++++++++++++++ classes/iterators/IsisMethodIterator.php | 63 +++++++++++++++++ .../iterators/IsisNormalSubfieldFilterIterator.php | 14 ++++ classes/iterators/IsisRowIterator.php | 58 ++++++++++++++++ classes/iterators/IsisSubfieldIterator.php | 75 ++++++++++++++++++++ classes/iterators/IsisValueIterator.php | 62 +++++++++++++++++ 12 files changed, 351 insertions(+), 351 deletions(-) delete mode 100644 classes/IsisFieldIterator.php delete mode 100644 classes/IsisMethodIterator.php delete mode 100644 classes/IsisNormalSubfieldFilterIterator.php delete mode 100644 classes/IsisRowIterator.php delete mode 100644 classes/IsisSubfieldIterator.php delete mode 100644 classes/IsisValueIterator.php create mode 100644 classes/iterators/IsisFieldIterator.php create mode 100644 classes/iterators/IsisMethodIterator.php create mode 100644 classes/iterators/IsisNormalSubfieldFilterIterator.php create mode 100644 classes/iterators/IsisRowIterator.php create mode 100644 classes/iterators/IsisSubfieldIterator.php create mode 100644 classes/iterators/IsisValueIterator.php (limited to 'classes') diff --git a/classes/IsisFieldIterator.php b/classes/IsisFieldIterator.php deleted file mode 100644 index 11ed979..0000000 --- a/classes/IsisFieldIterator.php +++ /dev/null @@ -1,79 +0,0 @@ -rows = $class->getRows($field); - $this->valueset = $class->getValues($field); - } - - /** - * Rewind the Iterator to the first element. - */ - function rewind() { - $this->row = 0; - $this->value = 0; - } - - /** - * Return the key of the current element. - */ - function key() { - return $this->row; - } - - /** - * Return the current element. - */ - function current() { - return $this->valueset[$this->row]['field']; - } - - /** - * Move forward to next element. - */ - function next() { - do { - ++$this->row; - } - while ($this->current_null() && $this->has_more_rows()); - } - - /** - * Check if there are more rows. - */ - function has_more_rows() { - return $this->row <= $this->rows; - } - - /** - * Check if the current value is null. - */ - function current_null() { - return $this->current() == NULL; - } - - /** - * Check if there is a current element after calls to rewind() or next(). - */ - function valid() { - return $this->has_more_rows() && !$this->current_null(); - } -} diff --git a/classes/IsisMethodIterator.php b/classes/IsisMethodIterator.php deleted file mode 100644 index 4e5871c..0000000 --- a/classes/IsisMethodIterator.php +++ /dev/null @@ -1,63 +0,0 @@ -class = $class; - $this->total = count($class->fields); - $this->keys = array_keys($class->fields); - } - - /** - * Rewind the Iterator to the first element. - */ - function rewind() { - $this->position = 0; - } - - /** - * Return the key of the current element. - */ - function key() { - $type = $this->class->getMapType($this->current()); - return $this->class->methodName($type); - } - - /** - * Return the current element. - */ - function current() { - return $this->class->fields[$this->keys[$this->position]]; - } - - /** - * Move forward to next element. The method should be callable, otherwise - * we move to the next position. - */ - function next() { - do { - ++$this->position; - } - while (!is_callable(array($this->class, $this->key())) && $this->valid()); - } - - /** - * Check if there is a current element after calls to rewind() or next(). - */ - function valid() { - return $this->position <= $this->total; - } -} diff --git a/classes/IsisNormalSubfieldFilterIterator.php b/classes/IsisNormalSubfieldFilterIterator.php deleted file mode 100644 index 98494a6..0000000 --- a/classes/IsisNormalSubfieldFilterIterator.php +++ /dev/null @@ -1,14 +0,0 @@ -getInnerIterator()->field; - $class = $this->getInnerIterator()->class; - $subfield = $this->getInnerIterator()->current(); - return !$class->specialSubfield($field, $subfield); - } -} diff --git a/classes/IsisRowIterator.php b/classes/IsisRowIterator.php deleted file mode 100644 index 739db22..0000000 --- a/classes/IsisRowIterator.php +++ /dev/null @@ -1,58 +0,0 @@ -rows = $class->getRows($field); - } - - /** - * Rewind the Iterator to the first element. - */ - function rewind() { - $this->row = 0; - } - - /** - * Return the key of the current element. - */ - function key() { - return $this->row; - } - - /** - * Return the current element. - */ - function current() { - return $this->row; - } - - /** - * Move forward to next element. - */ - function next() { - ++$this->row; - } - - /** - * Check if there is a current element after calls to rewind() or next(). - */ - function valid() { - return $this->row <= $this->rows; - } -} diff --git a/classes/IsisSubfieldIterator.php b/classes/IsisSubfieldIterator.php deleted file mode 100644 index 36d3d06..0000000 --- a/classes/IsisSubfieldIterator.php +++ /dev/null @@ -1,75 +0,0 @@ -class = $class; - $this->field = $field; - $this->rows = $class->getRows($field); - $this->fieldset = $class->getSubfieldList($field); - $this->keys = array_keys($this->fieldset); - $this->subfields = count($this->keys); - } - - /** - * Rewind the Iterator to the first element. - */ - function rewind() { - $this->row = 0; - $this->subfield = 0; - } - - /** - * Return the key of the current element. - */ - function key() { - return $this->row; - } - - /** - * Return the current element. - */ - function current() { - return $this->fieldset[$this->keys[$this->subfield]]; - } - - /** - * Move forward to next element. - */ - function next() { - if ($this->subfield >= $this->subfields) { - $this->subfield = 0; - ++$this->row; - } - else { - ++$this->subfield; - } - } - - /** - * Check if there is a current element after calls to rewind() or next(). - */ - function valid() { - return $this->row <= $this->rows; - } -} diff --git a/classes/IsisValueIterator.php b/classes/IsisValueIterator.php deleted file mode 100644 index f10125d..0000000 --- a/classes/IsisValueIterator.php +++ /dev/null @@ -1,62 +0,0 @@ -rows = $class->getRows($field); - $this->valueset = $class->getValues($field); - } - - /** - * Rewind the Iterator to the first element. - */ - function rewind() { - $this->row = 0; - $this->value = 0; - } - - /** - * Return the key of the current element. - */ - function key() { - return $this->row; - } - - /** - * Return the current element. - */ - function current() { - return $this->valueset[$this->row]; - } - - /** - * Move forward to next element. - */ - function next() { - ++$this->row; - } - - /** - * Check if there is a current element after calls to rewind() or next(). - */ - function valid() { - return $this->row <= $this->rows; - } -} diff --git a/classes/iterators/IsisFieldIterator.php b/classes/iterators/IsisFieldIterator.php new file mode 100644 index 0000000..11ed979 --- /dev/null +++ b/classes/iterators/IsisFieldIterator.php @@ -0,0 +1,79 @@ +rows = $class->getRows($field); + $this->valueset = $class->getValues($field); + } + + /** + * Rewind the Iterator to the first element. + */ + function rewind() { + $this->row = 0; + $this->value = 0; + } + + /** + * Return the key of the current element. + */ + function key() { + return $this->row; + } + + /** + * Return the current element. + */ + function current() { + return $this->valueset[$this->row]['field']; + } + + /** + * Move forward to next element. + */ + function next() { + do { + ++$this->row; + } + while ($this->current_null() && $this->has_more_rows()); + } + + /** + * Check if there are more rows. + */ + function has_more_rows() { + return $this->row <= $this->rows; + } + + /** + * Check if the current value is null. + */ + function current_null() { + return $this->current() == NULL; + } + + /** + * Check if there is a current element after calls to rewind() or next(). + */ + function valid() { + return $this->has_more_rows() && !$this->current_null(); + } +} diff --git a/classes/iterators/IsisMethodIterator.php b/classes/iterators/IsisMethodIterator.php new file mode 100644 index 0000000..4e5871c --- /dev/null +++ b/classes/iterators/IsisMethodIterator.php @@ -0,0 +1,63 @@ +class = $class; + $this->total = count($class->fields); + $this->keys = array_keys($class->fields); + } + + /** + * Rewind the Iterator to the first element. + */ + function rewind() { + $this->position = 0; + } + + /** + * Return the key of the current element. + */ + function key() { + $type = $this->class->getMapType($this->current()); + return $this->class->methodName($type); + } + + /** + * Return the current element. + */ + function current() { + return $this->class->fields[$this->keys[$this->position]]; + } + + /** + * Move forward to next element. The method should be callable, otherwise + * we move to the next position. + */ + function next() { + do { + ++$this->position; + } + while (!is_callable(array($this->class, $this->key())) && $this->valid()); + } + + /** + * Check if there is a current element after calls to rewind() or next(). + */ + function valid() { + return $this->position <= $this->total; + } +} diff --git a/classes/iterators/IsisNormalSubfieldFilterIterator.php b/classes/iterators/IsisNormalSubfieldFilterIterator.php new file mode 100644 index 0000000..98494a6 --- /dev/null +++ b/classes/iterators/IsisNormalSubfieldFilterIterator.php @@ -0,0 +1,14 @@ +getInnerIterator()->field; + $class = $this->getInnerIterator()->class; + $subfield = $this->getInnerIterator()->current(); + return !$class->specialSubfield($field, $subfield); + } +} diff --git a/classes/iterators/IsisRowIterator.php b/classes/iterators/IsisRowIterator.php new file mode 100644 index 0000000..739db22 --- /dev/null +++ b/classes/iterators/IsisRowIterator.php @@ -0,0 +1,58 @@ +rows = $class->getRows($field); + } + + /** + * Rewind the Iterator to the first element. + */ + function rewind() { + $this->row = 0; + } + + /** + * Return the key of the current element. + */ + function key() { + return $this->row; + } + + /** + * Return the current element. + */ + function current() { + return $this->row; + } + + /** + * Move forward to next element. + */ + function next() { + ++$this->row; + } + + /** + * Check if there is a current element after calls to rewind() or next(). + */ + function valid() { + return $this->row <= $this->rows; + } +} diff --git a/classes/iterators/IsisSubfieldIterator.php b/classes/iterators/IsisSubfieldIterator.php new file mode 100644 index 0000000..36d3d06 --- /dev/null +++ b/classes/iterators/IsisSubfieldIterator.php @@ -0,0 +1,75 @@ +class = $class; + $this->field = $field; + $this->rows = $class->getRows($field); + $this->fieldset = $class->getSubfieldList($field); + $this->keys = array_keys($this->fieldset); + $this->subfields = count($this->keys); + } + + /** + * Rewind the Iterator to the first element. + */ + function rewind() { + $this->row = 0; + $this->subfield = 0; + } + + /** + * Return the key of the current element. + */ + function key() { + return $this->row; + } + + /** + * Return the current element. + */ + function current() { + return $this->fieldset[$this->keys[$this->subfield]]; + } + + /** + * Move forward to next element. + */ + function next() { + if ($this->subfield >= $this->subfields) { + $this->subfield = 0; + ++$this->row; + } + else { + ++$this->subfield; + } + } + + /** + * Check if there is a current element after calls to rewind() or next(). + */ + function valid() { + return $this->row <= $this->rows; + } +} diff --git a/classes/iterators/IsisValueIterator.php b/classes/iterators/IsisValueIterator.php new file mode 100644 index 0000000..f10125d --- /dev/null +++ b/classes/iterators/IsisValueIterator.php @@ -0,0 +1,62 @@ +rows = $class->getRows($field); + $this->valueset = $class->getValues($field); + } + + /** + * Rewind the Iterator to the first element. + */ + function rewind() { + $this->row = 0; + $this->value = 0; + } + + /** + * Return the key of the current element. + */ + function key() { + return $this->row; + } + + /** + * Return the current element. + */ + function current() { + return $this->valueset[$this->row]; + } + + /** + * Move forward to next element. + */ + function next() { + ++$this->row; + } + + /** + * Check if there is a current element after calls to rewind() or next(). + */ + function valid() { + return $this->row <= $this->rows; + } +} -- cgit v1.2.3