Cytoscape 2.8.0 API

cytoscape.data
Class CyAttributesUtils

java.lang.Object
  extended by cytoscape.data.CyAttributesUtils

public class CyAttributesUtils
extends Object


Nested Class Summary
static class CyAttributesUtils.AttributeType
           
 
Field Summary
static AttributeFilter ALL_ATTRIBUTES_FILTER
          An AttributeFilter that produces all attributes--none are filtered out.
 
Constructor Summary
CyAttributesUtils()
           
 
Method Summary
static boolean copyAttribute(CyAttributes attribs, String sourceId, String targetId, String attribName, boolean copyEquation, StringBuilder errorMessage)
           
static void copyAttribute(String originalID, String copyID, String attrName, CyAttributes attrs, boolean purge)
          Copy a specific attribute of a given object to another object.
static void copyAttributes(String originalID, String copyID, CyAttributes attrs, AttributeFilter filter, boolean purge)
          Copy all the attributes of a given object that pass a given filter to another object.
static void copyAttributes(String originalID, String copyID, CyAttributes attrs, boolean purge)
          Copy all the attributes of a given object to another object.
static Map getAttribute(String attributeName, CyAttributes attrs)
          DOCUMENT ME!
static List<String> getAttributeNamesForObj(String objID, CyAttributes attrs)
          Return a non-null List of all the attribute names associated with a given identifier for a given CyAttributes.
static Map<String,Object> getAttributes(String canonicalName, CyAttributes attrs)
          DOCUMENT ME!
static Class getClass(String attributeName, CyAttributes attrs)
          DOCUMENT ME!
static List<String> getIDListFromAttributeValue(CyAttributesUtils.AttributeType type, String attrName, Object attrValue)
          Get list of IDs associated with a specific attribute value.
static List<String> getVisibleAttributeNames(CyAttributes attrs)
          DOCUMENT ME!
static boolean isNullAttribute(String attributeType, String attributeName)
          Check if all the values for an attribute are NULL.
static byte toByte(String attributeType)
          Return a byte representation of the various CyAttributes types returned by methods like CyAttributes.getType() and MultiHashMapDefinition.getAttributeKeysapceDimensionTypes().
static String toString(byte atype)
          Return a String representation of the various CyAttributes types returned by methods like CyAttributes.getType() and MultiHashMapDefinition.getAttributeKeysapceDimensionTypes().
static void traverseAttributeValues(String objToTraverseID, String attrName, CyAttributes attrs, AttributeValueVisitor visitor)
          Traverse all the values of a given attribute applying an AttributeValueVisitor to each value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_ATTRIBUTES_FILTER

public static final AttributeFilter ALL_ATTRIBUTES_FILTER
An AttributeFilter that produces all attributes--none are filtered out.

Constructor Detail

CyAttributesUtils

public CyAttributesUtils()
Method Detail

getAttribute

public static Map getAttribute(String attributeName,
                               CyAttributes attrs)
DOCUMENT ME!

Parameters:
attributeName - DOCUMENT ME!
attrs - DOCUMENT ME!
Returns:
DOCUMENT ME!

getAttributes

public static Map<String,Object> getAttributes(String canonicalName,
                                               CyAttributes attrs)
DOCUMENT ME!

Parameters:
canonicalName - DOCUMENT ME!
attrs - DOCUMENT ME!
Returns:
DOCUMENT ME!

getClass

public static Class getClass(String attributeName,
                             CyAttributes attrs)
DOCUMENT ME!

Parameters:
attributeName - DOCUMENT ME!
attrs - DOCUMENT ME!
Returns:
DOCUMENT ME!

getVisibleAttributeNames

public static List<String> getVisibleAttributeNames(CyAttributes attrs)
DOCUMENT ME!

Parameters:
attrs - DOCUMENT ME!
Returns:
DOCUMENT ME!

copyAttribute

public static boolean copyAttribute(CyAttributes attribs,
                                    String sourceId,
                                    String targetId,
                                    String attribName,
                                    boolean copyEquation,
                                    StringBuilder errorMessage)
Parameters:
copyEquation - if true, and the source contains an equation, the equation and not the value will be copied
errorMessage - will be set to an explanatory text should the copy operation fail
Returns:
true if the copy operation succeeded, else false

copyAttributes

public static void copyAttributes(String originalID,
                                  String copyID,
                                  CyAttributes attrs,
                                  boolean purge)
Copy all the attributes of a given object to another object. Equivalent to:
    copyAttributes (originalID, copyID, attrs, ALL_ATTRIBUTES_FILTER, purge).
 

See Also:
copyAttributes(String,String,CyAttributes,AttributeFilter,boolean)

copyAttributes

public static void copyAttributes(String originalID,
                                  String copyID,
                                  CyAttributes attrs,
                                  AttributeFilter filter,
                                  boolean purge)
Copy all the attributes of a given object that pass a given filter to another object. This includes complex attributes.

Parameters:
originalID - the identifier of the object we are copying from (e.g, equivalent to CyNode.getIdentifier()).
copyID - the identifier of the object we are copying to.
attrs - the CyAttributes from which to copy and retrieve the attributes.
filter - an AttributeFilter that determines if a given attribute should be copied. The filter is applied to all attributes stored un originalID. An attribute will we copied iff filter.includeAttribute() returns true. To copy all attributes, use ALL_ATTRIBUTES_FILTER.
purge - true iff existing attribute values associated with the object represented by copyID are to be removed before copying the new attribute values from the object represented by originalID. This is useful when copying to an existing object that contained previous attribute values. This should be false for newly created, objects that have no previous attribute values.
Throws:
IllegalArgumentException - if originalID, copyID, attrs, or filter are null; or if originalID==copyID.

copyAttribute

public static void copyAttribute(String originalID,
                                 String copyID,
                                 String attrName,
                                 CyAttributes attrs,
                                 boolean purge)
Copy a specific attribute of a given object to another object. This includes complex attributes.

Parameters:
originalID - the identifier of the object we are copying from (e.g, equivalent to CyNode.getIdentifier()).
copyID - the identifier of the object we are copying to.
attrName - the name of the attribute we wish to copy.
attrs - the CyAttributes from which to copy and retrieve the attribute.
purge - true iff existing attribute values associated with the object represented by copyID are to be removed before copying the new attribute values from the object represented by originalID. This is useful when copying to an existing object that contained previous attribute values. This should be false for newly created, objects that have no previous attribute values.
Throws:
IllegalArgumentException - if originalID, copyID, attrName, or attrs are null; or if originalID==copyID.

traverseAttributeValues

public static void traverseAttributeValues(String objToTraverseID,
                                           String attrName,
                                           CyAttributes attrs,
                                           AttributeValueVisitor visitor)
Traverse all the values of a given attribute applying an AttributeValueVisitor to each value. For simple attributes, such as those of type CyAttributes.TYPE_INTEGER or CyAttributes.TYPE_STRING, a single value is traversed. For Lists, Maps, and complex attribute types, all attribute values are traversed--applying the given AttributeValueVisitor to each value.

Parameters:
objToTraverseID - the identifier of the object containing the attribute of interest.
attrName - the name of the attribute for which we are to traverse values.
attrs - the CyAttributes that contains the attribute of interest.
visitor - an AttributeValueVisitor to be applied to each value of the attribute being traversed. For example, to print out all attribute values, we could perform:
     traverseAttributeValues ("testObject",
                              "testAttributeName",
                              Cytoscape.getNodeAttributes(),
                              new AttributeValueVisitor () {
              public void visitingAttributeValue (String objTraversedID,
                                                  String attrName,
                                                  CyAttributes attrs,
                                                  Object[] keySpace,
                                                  Object visitedValue) {
                  CyLogger.getLogger().info ("traversing " + visitedValue);
              }});
 
No traversal is performed if objToTraverseID or attrName are null, or if objToTraverseID has no associated attrName attribute.

getAttributeNamesForObj

public static List<String> getAttributeNamesForObj(String objID,
                                                   CyAttributes attrs)
Return a non-null List of all the attribute names associated with a given identifier for a given CyAttributes. Will return an empty list if objID or attrs is null.

Parameters:
objID - the identifier of the object of interest.
attrs - the CyAttributes from which to check for attributes.

getIDListFromAttributeValue

public static List<String> getIDListFromAttributeValue(CyAttributesUtils.AttributeType type,
                                                       String attrName,
                                                       Object attrValue)
Get list of IDs associated with a specific attribute value.

Parameters:
attr - DOCUMENT ME!
attrName - DOCUMENT ME!
attrValue - DOCUMENT ME!
Returns:
DOCUMENT ME!

toString

public static String toString(byte atype)
Return a String representation of the various CyAttributes types returned by methods like CyAttributes.getType() and MultiHashMapDefinition.getAttributeKeysapceDimensionTypes(). This is useful for "toString()" operations.

See Also:
CyAttributes.getType(java.lang.String), MultiHashMapDefinition.getAttributeKeyspaceDimensionTypes(java.lang.String)

toByte

public static byte toByte(String attributeType)
Return a byte representation of the various CyAttributes types returned by methods like CyAttributes.getType() and MultiHashMapDefinition.getAttributeKeysapceDimensionTypes(). This is useful to return the byte when you have an Attribute String.

See Also:
CyAttributes.getType(java.lang.String), MultiHashMapDefinition.getAttributeKeyspaceDimensionTypes(java.lang.String)

isNullAttribute

public static boolean isNullAttribute(String attributeType,
                                      String attributeName)
Check if all the values for an attribute are NULL.

Parameters:
attributeType - "node" or "edge"
attributeName - attribute name.

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.