+ @Override
+ public TemplateModelIterator iterator() throws TemplateModelException {
+ return new TemplateModelIterator() {
+
+ @Override
+ public TemplateModel next() throws TemplateModelException {
+ try {
+ return new SimpleScalar(pit.nextProperty().getName());
+ } catch (RepositoryException e) {
+ throw new TemplateModelException("Cannot list properties of " + node, e);
+ }
+ }
+
+ @Override
+ public boolean hasNext() throws TemplateModelException {
+ return pit.hasNext();
+ }
+ };
+ }
+ };
+ } catch (RepositoryException e) {
+ throw new TemplateModelException("Cannot list properties of " + node, e);
+ }
+ }
+
+ @Override
+ public int size() throws TemplateModelException {
+ try {
+ PropertyIterator pit = node.getProperties();
+ return (int) pit.getSize();
+ } catch (RepositoryException e) {
+ throw new TemplateModelException("Cannot list properties of " + node, e);
+ }
+ }
+
+ @Override
+ public TemplateCollectionModel values() throws TemplateModelException {
+ try {
+ PropertyIterator pit = node.getProperties();
+ return new TemplateCollectionModel() {
+
+ @Override
+ public TemplateModelIterator iterator() throws TemplateModelException {
+ return new TemplateModelIterator() {
+
+ @Override
+ public TemplateModel next() throws TemplateModelException {
+ try {
+ return propertyValues(pit.nextProperty());
+ } catch (RepositoryException e) {
+ throw new TemplateModelException("Cannot list properties of " + node, e);
+ }
+ }
+
+ @Override
+ public boolean hasNext() throws TemplateModelException {
+ return pit.hasNext();
+ }
+ };
+ }
+ };
+ } catch (RepositoryException e) {
+ throw new TemplateModelException("Cannot list properties of " + node, e);
+ }
+ }
+
+ @Override
+ public KeyValuePairIterator keyValuePairIterator() throws TemplateModelException {
+ try {
+ PropertyIterator pit = node.getProperties();
+ return new KeyValuePairIterator() {
+
+ @Override
+ public boolean hasNext() throws TemplateModelException {
+ return pit.hasNext();
+ }
+
+ @Override
+ public KeyValuePair next() throws TemplateModelException {
+ Property property = pit.nextProperty();
+ return new KeyValuePair() {
+
+ @Override
+ public TemplateModel getValue() throws TemplateModelException {
+ try {
+ return propertyValues(property);
+ } catch (RepositoryException e) {
+ throw new TemplateModelException("Cannot list properties of " + node, e);
+ }
+ }
+
+ @Override
+ public TemplateModel getKey() throws TemplateModelException {
+ try {
+ return new SimpleScalar(property.getName());
+ } catch (RepositoryException e) {
+ throw new TemplateModelException("Cannot list properties of " + node, e);
+ }
+ }
+ };
+ }
+ };
+ } catch (RepositoryException e) {
+ throw new TemplateModelException("Cannot list properties of " + node, e);
+ }
+ }
+
+ }