Author: andreas
Date: Tue Apr 22 16:10:42 2008
New Revision: 650694
URL: http://svn.apache.org/viewvc?rev=650694&view=rev
Log:
Adding SubtreeAndSiblingsSelector and javadocs.
Added:
lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeAndSiblingsSelector.java
Modified:
lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/BreadcrumbSelector.java
lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/ChildrenSelector.java
lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/LanguagesSelector.java
lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeSelector.java
Modified: lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/BreadcrumbSelector.java
URL: http://svn.apache.org/viewvc/lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/BreadcrumbSelector.java?rev=650694&r1=650693&r2=650694&view=diff
==============================================================================
--- lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/BreadcrumbSelector.java (original)
+++ lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/BreadcrumbSelector.java Tue Apr 22 16:10:42 2008
@@ -24,6 +24,11 @@
import org.apache.lenya.cms.site.SiteStructure;
import org.xml.sax.SAXException;
+/**
+ * Generate the nodes from the top-level node down to the node identified by the
+ * <em>path</em> parameter. Only the links of the currently selected language
+ * are included.
+ */
public class BreadcrumbSelector implements FragmentSelector {
public void selectFragment(NodeGenerator generator, SiteStructure site, String path, String lang)
Modified: lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/ChildrenSelector.java
URL: http://svn.apache.org/viewvc/lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/ChildrenSelector.java?rev=650694&r1=650693&r2=650694&view=diff
==============================================================================
--- lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/ChildrenSelector.java (original)
+++ lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/ChildrenSelector.java Tue Apr 22 16:10:42 2008
@@ -23,8 +23,9 @@
import org.xml.sax.SAXException;
/**
- * Select the child nodes of a node non-recursively. If the path is "" or "/",
- * the top-level nodes are generated.
+ * Select the child nodes of the node identified by the <em>path</em>
+ * parameter non-recursively. If the path is "" or "/", the top-level nodes are
+ * generated.
*/
public class ChildrenSelector implements FragmentSelector {
Modified: lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/LanguagesSelector.java
URL: http://svn.apache.org/viewvc/lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/LanguagesSelector.java?rev=650694&r1=650693&r2=650694&view=diff
==============================================================================
--- lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/LanguagesSelector.java (original)
+++ lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/LanguagesSelector.java Tue Apr 22 16:10:42 2008
@@ -22,6 +22,10 @@
import org.apache.lenya.cms.site.SiteStructure;
import org.xml.sax.SAXException;
+/**
+ * Select the node which is identified by the <em>path</em> parameter and its
+ * links. The currently selected link will have the attribute <em>current="true"</em>.
+ */
public class LanguagesSelector implements FragmentSelector {
public void selectFragment(NodeGenerator generator, SiteStructure site, String path,
Added: lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeAndSiblingsSelector.java
URL: http://svn.apache.org/viewvc/lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeAndSiblingsSelector.java?rev=650694&view=auto
==============================================================================
--- lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeAndSiblingsSelector.java (added)
+++ lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeAndSiblingsSelector.java Tue Apr 22 16:10:42 2008
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.modules.navigation;
+
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.SiteNode;
+import org.apache.lenya.cms.site.SiteStructure;
+import org.xml.sax.SAXException;
+
+/**
+ * Select the node identified by the <em>path</em> parameter, its siblings,
+ * and its children recursively. If the path is "" or "/", the nodes of the
+ * whole site are generated. Only the links for the currently selected language
+ * are generated.
+ */
+public class SubtreeAndSiblingsSelector implements FragmentSelector {
+
+ public void selectFragment(NodeGenerator generator, SiteStructure site, String path, String lang)
+ throws SAXException, SiteException {
+ if (path.equals("/") || path.equals("")) {
+ SiteNode[] nodes = site.getTopLevelNodes();
+ selectNodes(generator, nodes, lang);
+ } else if (site.contains(path)) {
+ SiteNode node = site.getNode(path);
+ SiteNode[] siblings = getSiblings(node);
+ for (int i = 0; i < siblings.length; i++) {
+ if (siblings[i] == node) {
+ selectSubtree(generator, siblings[i], lang);
+ } else {
+ selectNode(generator, siblings[i], lang);
+ }
+ }
+ }
+ }
+
+ protected void selectNode(NodeGenerator generator, SiteNode node, String lang)
+ throws SAXException {
+ generator.startNode(node);
+ generator.generateLink(node, lang);
+ generator.endNode(node);
+ }
+
+ protected SiteNode[] getSiblings(SiteNode node) throws SiteException {
+ return node.isTopLevel() ? node.getStructure().getTopLevelNodes() : node.getParent()
+ .getChildren();
+ }
+
+ protected void selectSubtree(NodeGenerator generator, SiteNode node, String lang)
+ throws SAXException {
+ generator.startNode(node);
+ generator.generateLink(node, lang);
+ selectNodes(generator, node.getChildren(), lang);
+ generator.endNode(node);
+ }
+
+ protected void selectNodes(NodeGenerator generator, SiteNode[] nodes, String lang)
+ throws SAXException {
+ for (int i = 0; i < nodes.length; i++) {
+ selectSubtree(generator, nodes[i], lang);
+ }
+ }
+
+}
Modified: lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeSelector.java
URL: http://svn.apache.org/viewvc/lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeSelector.java?rev=650694&r1=650693&r2=650694&view=diff
==============================================================================
--- lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeSelector.java (original)
+++ lenya/docu/modules/navigation/java/src/org/apache/lenya/modules/navigation/SubtreeSelector.java Tue Apr 22 16:10:42 2008
@@ -23,8 +23,9 @@
import org.xml.sax.SAXException;
/**
- * Select a node and its children recursively. If the path is "" or "/", the
- * whole site is generated.
+ * Select the node identified by the <em>path</em> parameter and its children
+ * recursively. If the path is "" or "/", the nodes of the whole site are
+ * generated. Only the links for the currently selected language are included.
*/
public class SubtreeSelector implements FragmentSelector {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.