001: //$$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/io/datastore/sql/wherebuilder/FeaturePropertyNode.java $$
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstr. 19
030: 53115 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042:
043: ---------------------------------------------------------------------------*/
044:
045: package org.deegree.io.datastore.sql.wherebuilder;
046:
047: import java.util.ArrayList;
048: import java.util.Collection;
049: import java.util.Iterator;
050:
051: import org.deegree.io.datastore.schema.MappedFeaturePropertyType;
052:
053: /**
054: * Represents a {@link MappedFeaturePropertyType} as a node in a {@link QueryTableTree}.
055: *
056: * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a>
057: * @author last edited by: $Author: aschmitz $
058: *
059: * @version $Revision: 10506 $, $Date: 2008-03-06 08:50:33 -0800 (Thu, 06 Mar 2008) $
060: */
061: class FeaturePropertyNode extends AbstractPropertyNode {
062:
063: private Collection<FeatureTypeNode> children = new ArrayList<FeatureTypeNode>();
064:
065: /**
066: * Creates a new <code>FeaturePropertyNode</code> instance from the given parameters.
067: *
068: * @param property
069: * the PropertyType that this FeaturePropertyNode represents
070: * @param parent
071: * @param tableAliases
072: * the aliases for the tables that lead from the parent feature type node's table to
073: * the table where the property's value is stored
074: */
075: FeaturePropertyNode(MappedFeaturePropertyType property,
076: FeatureTypeNode parent, String[] tableAliases) {
077: super (property, parent, tableAliases);
078: }
079:
080: /**
081: * Returns the children of this <code>FeaturePropertyNode</code>.
082: *
083: * @return the children of this FeaturePropertyNode.
084: */
085: public FeatureTypeNode[] getFeatureTypeNodes() {
086: return this .children.toArray(new FeatureTypeNode[this .children
087: .size()]);
088: }
089:
090: /**
091: * Adds a new child to this <code>FeaturePropertyNode</code>.
092: *
093: * @param newFeatureTypeNode child node to add
094: */
095: public void addFeatureTypeNode(FeatureTypeNode newFeatureTypeNode) {
096: this .children.add(newFeatureTypeNode);
097: }
098:
099: @Override
100: public String toString(String indent) {
101:
102: StringBuffer sb = new StringBuffer();
103: sb.append(indent);
104: sb.append("+ ");
105: sb.append(this .getProperty().getName());
106: sb.append(" (FeaturePropertyNode");
107: if (this .getTableAliases() != null) {
108: for (int i = 0; i < this .getTableAliases().length; i++) {
109: sb.append(" [");
110: sb.append(getPathFromParent()[i]);
111: sb.append(" target alias: '");
112: sb.append(getTableAliases()[i]);
113: sb.append("'");
114: if (i != this .getTableAliases().length - 1) {
115: sb.append(", ");
116: } else {
117: sb.append("]");
118: }
119: }
120: }
121: sb.append(")\n");
122: Iterator<FeatureTypeNode> iter = this .children.iterator();
123: while (iter.hasNext()) {
124: FeatureTypeNode child = iter.next();
125: sb.append(child.toString(indent + " "));
126: }
127: return sb.toString();
128: }
129: }
|