cb.petal.ClassCategory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.crazybeans Show documentation
Show all versions of org.crazybeans Show documentation
Java library to read, modify or create Rational Rose petal files
The newest version!
/**
* Copyright (c) 2001 Markus Dahm
* Copyright (C) 2015-2018 BITPlan GmbH http://www.bitplan.com
*
* This source is part of
* https://github.com/BITPlan/CrazyBeans
* and the license as outlined there applies
*/
package cb.petal;
import java.util.Arrays;
import java.util.Iterator;
/**
* Class category is used for structuring into submodels and -views, it may
* contain further class categories.
*
* @version $Id: ClassCategory.java,v 1.17 2002/09/03 19:33:02 dahm Exp $
* @author M. Dahm
*/
public class ClassCategory extends NamedQuidObject implements AccessQualified,
Named, Documented, StereoTyped {
static final long serialVersionUID = -8273790375346338894L;
protected ClassCategory(PetalNode parent, String name) {
super(parent, "Class_Category", Arrays.asList(new String[] { name }));
}
public ClassCategory() {
this(null, "Class Category");
}
public String getDocumentation() {
return getPropertyAsString("documentation");
}
public void setDocumentation(String o) {
defineProperty("documentation", o);
}
public String getExportControl() {
return getPropertyAsString("exportControl");
}
public void setExportControl(String o) {
defineProperty("exportControl", o);
}
public boolean getGlobal() {
return getPropertyAsBoolean("global");
}
public void setGlobal(boolean o) {
defineProperty("global", o);
}
/**
* The returned values depend on what kind of class category this is. In the
* logical view this returns class, association and mechanism objects. It may
* of course also contain further ClassCategory objects.
*/
public PetalNodeList getLogicalModels() {
return (PetalNodeList) getProperty("logical_models");
}
/**
* set the Logical models
*
* @param o
*/
public void setLogicalModels(PetalNodeList o) {
defineProperty("logical_models", o);
}
/**
* This returns a list of diagrams, ClassDiagram objects, e.g.
*/
public PetalNodeList getLogicalPresentations() {
return (PetalNodeList) getProperty("logical_presentations");
}
public void setLogicalPresentations(PetalNodeList o) {
defineProperty("logical_presentations", o);
}
/**
* Find diagram by given class
*/
protected java.lang.Object lookupDiagram(java.lang.Class clazz) {
PetalNodeList list = getLogicalPresentations();
if ((list == null) || (list.size() == 0))
return null;
else {
for (Iterator i = list.getElements().iterator(); i.hasNext();) {
java.lang.Object o = i.next();
if (o.getClass() == clazz)
return o;
}
}
return null;
}
protected void add(PetalObject obj) {
getLogicalModels().add(obj);
obj.setParent(this);
obj.init();
}
protected void remove(PetalObject obj) {
getLogicalModels().remove(obj);
obj.setParent(null);
}
public void addToModel(Association assoc) {
add(assoc);
}
public void removeFromModel(Association assoc) {
remove(assoc);
}
public String getStereotype() {
return getPropertyAsString("stereotype");
}
public void setStereotype(String c) {
defineProperty("stereotype", c);
}
/**
* Add a class to the model. Sets parent and calls init() on class.
*/
public void addToModel(Class clazz) {
add(clazz);
}
public void removeFromModel(Class clazz) {
remove(clazz);
}
public void accept(Visitor v) {
v.visit(this);
}
}