001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2002, Refractions Reserach Inc.
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.graph.structure.opt;
018:
019: import java.io.Serializable;
020:
021: import org.geotools.graph.structure.Graphable;
022:
023: /**
024: * Root of class hierarchy for optimized implementation of graph components.
025: * The optimizations reduce the space taken up by graph components: <BR>
026: * <UL>
027: * <LI>Counter implemented as byte
028: * <LI>No underlying object reference.
029: * </UL>
030: * Objects in the optimized hierarchy implement the Serializable interface.
031: *
032: * @author Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
033: * @see Graphable
034: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/graph/src/main/java/org/geotools/graph/structure/opt/OptGraphable.java $
035: */
036: public abstract class OptGraphable implements Graphable, Serializable {
037:
038: /** visited flag **/
039: private boolean m_visited;
040:
041: /** counter **/
042: private byte m_count;
043:
044: /**
045: * Constructs a new optimized graphable object. Visited flag it set to false
046: * and counter set to -1.
047: */
048: public OptGraphable() {
049: m_visited = false;
050: m_count = -1;
051: }
052:
053: /**
054: * Does nothing.
055: *
056: * @see Graphable#setID(int)
057: */
058: public void setID(int id) {
059: }
060:
061: /**
062: * Returns 0.
063: *
064: * @see Graphable#getID()
065: */
066: public int getID() {
067: return 0;
068: }
069:
070: /**
071: * @see Graphable#setVisited(boolean)
072: */
073: public void setVisited(boolean visited) {
074: m_visited = visited;
075: }
076:
077: /**
078: * @see Graphable#isVisited()
079: */
080: public boolean isVisited() {
081: return (m_visited);
082: }
083:
084: /**
085: * To minimize space, the counter is stored as a byte. Therefore the counter
086: * can take on values from -128 to 127.
087: *
088: * @see Graphable#setCount(int)
089: */
090: public void setCount(int count) {
091: m_count = (byte) count;
092: }
093:
094: /**
095: * @see Graphable#getCount()
096: */
097: public int getCount() {
098: return (m_count);
099: }
100:
101: /**
102: * Does nothing.
103: *
104: * @see Graphable#setObject(Object)
105: */
106: public void setObject(Object obj) {
107: }
108:
109: /**
110: * Returns null.
111: *
112: * @see Graphable#getObject()
113: */
114: public Object getObject() {
115: return null;
116: }
117: }
|