From: <jrb...@us...> - 2009-10-21 19:17:49
|
Revision: 973 http://cishell.svn.sourceforge.net/cishell/?rev=973&view=rev Author: jrbibers Date: 2009-10-21 19:17:41 +0000 (Wed, 21 Oct 2009) Log Message: ----------- Added CIShell utility class "BasicDataPlus", which extends BasicData to add convenience constructors and methods. Hoping this will find use among developers when returning Data[] from the execute method of new Algorithms. Reviewed by Micah. Added Paths: ----------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/BasicDataPlus.java Added: trunk/core/org.cishell.utilities/src/org/cishell/utilities/BasicDataPlus.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/BasicDataPlus.java (rev 0) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/BasicDataPlus.java 2009-10-21 19:17:41 UTC (rev 973) @@ -0,0 +1,87 @@ +package org.cishell.utilities; + +import org.cishell.framework.data.BasicData; +import org.cishell.framework.data.Data; +import org.cishell.framework.data.DataProperty; + +/** + * Subclass adding only convenience methods and constructors, + * chiefly to the Dictionary of properties (metadata). + * <p/> + * These changes would be made to {@link Data} and {@link BasicData} + * rather than tacking on a subclass, but we are eager to keep existing code operable. + * <p/> + * Mind the difference between "format" and "type"! + */ +public class BasicDataPlus extends BasicData { + /** + * @param inner The object wrapped by this Data. + * @param format See {@link org.cishell.framework.data.Data#getFormat()}. + */ + public BasicDataPlus(Object inner, String format) { + super(inner, format); + } + + /** + * The inner data's format is assumed to be the toString value of its Class. + * + * @param inner The datum wrapped by this object. + */ + public BasicDataPlus(Object inner) { + this(inner, inner.getClass().toString()); + } + + /** + * + * @param inner The object wrapped by this Data. + * @param type The _TYPE constant from {@link DataProperty} + * that best characterizes the type of inner. + * @param parent The parent of inner. + */ + public BasicDataPlus(Object inner, String type, Data parent) { + this(inner); + setType(type); + setParent(parent); + } + + /** + * @see DataProperty#LABEL + */ + public void setLabel(String label) { + getMetadata().put(DataProperty.LABEL, label); + } + + /** + * @see DataProperty#SHORT_LABEL + */ + public void setShortLabel(String shortLabel) { + getMetadata().put(DataProperty.SHORT_LABEL, shortLabel); + } + + /** + * @see DataProperty#PARENT + */ + public void setParent(Data parent) { + getMetadata().put(DataProperty.PARENT, parent); + } + + /** + * @see DataProperty#TYPE + */ + public void setType(String type) { + getMetadata().put(DataProperty.TYPE, type); + } + + /** + * @see DataProperty#MODIFIED + */ + public void setModified(boolean modified) { + getMetadata().put(DataProperty.MODIFIED, new Boolean(modified)); + } + public void markAsModified() { + setModified(true); + } + public void markAsUnmodified() { + setModified(false); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |