/** * Returns a sorted (canonical) MetaData parameter list. * * <p>Don't change this method without considering its use in SignatureEvaluator.java */ public static String getSortedMetaDataParamString(MetaDataNode node) { final Set<Value> params = new TreeSet<Value>(metaDataValueComparator); final StringBuilder parameters = new StringBuilder(32); if (node.getValues() != null) { for (int i = 0, length = node.getValues().length; i < length; i++) { params.add(node.getValues()[i]); } final Iterator<Value> iter = params.iterator(); parameters.append('('); while (iter.hasNext()) { final Object v = iter.next(); if (v instanceof KeyValuePair) { final KeyValuePair pair = (KeyValuePair) v; parameters.append(pair.key).append("=\"").append(pair.obj).append('"'); } else { assert (v instanceof KeylessValue); parameters.append('"').append(((KeylessValue) v).obj).append('"'); } if (iter.hasNext()) { parameters.append(","); } } parameters.append(')'); } return parameters.toString(); }
/** * Returns the import name as it appeared in source code: E.g.: "Foo.Bar.*" if the source code was * "import Foo.Bar.*" * * <p>Don't change this method without considering its use in SignatureEvaluator.java */ public static String getDottedImportName(ImportDirectiveNode node) { final StringBuilder buf = new StringBuilder(); if (node.name != null && node.name.id.list != null) { for (final Iterator iter = node.name.id.list.iterator(); iter.hasNext(); ) { buf.append(((IdentifierNode) iter.next()).toIdentifierString()); if (iter.hasNext()) buf.append('.'); } } return buf.toString(); }
public static String setToString(Set<String> set, String delimiter) { final StringBuilder attributes = new StringBuilder(32); final Iterator<String> iter = set.iterator(); while (iter.hasNext()) { attributes.append(iter.next()); if (iter.hasNext()) attributes.append(delimiter); } return attributes.toString(); }
/** returns qualified class name in p.q:c format */ public static String getClassName(ClassDefinitionNode classDefinition) { if (classDefinition.cframe != null) { return classDefinition.cframe.name.toString(); } else { StringBuilder stringBuffer = new StringBuilder(getPackageName(classDefinition)); if (stringBuffer.length() > 0) { stringBuffer.append(":"); } stringBuffer.append(getUnqualifiedClassName(classDefinition)); return stringBuffer.toString(); } }
public static String retrieveClassName(MetaDataNode n) { String className = null; if (isClassDefinition(n)) { ClassDefinitionNode node = (ClassDefinitionNode) n.def; if (node.cframe != null) { className = node.cframe.name.toString().replace(':', '.'); } else { StringBuilder fullyQualifiedClassName = new StringBuilder(); fullyQualifiedClassName.append(NodeMagic.getPackageName(node)); if (fullyQualifiedClassName.length() > 0) { fullyQualifiedClassName.append('.'); } fullyQualifiedClassName.append(node.name.name); className = fullyQualifiedClassName.toString(); } } return className; }