本文整理汇总了Java中com.android.dx.rop.cst.CstString类的典型用法代码示例。如果您正苦于以下问题:Java CstString类的具体用法?Java CstString怎么用?Java CstString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CstString类属于com.android.dx.rop.cst包,在下文中一共展示了CstString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseElement
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Parses a {@link NameValuePair}.
*
* @return {@code non-null;} the parsed element
*/
private NameValuePair parseElement() throws IOException {
requireLength(5);
int elementNameIndex = input.readUnsignedShort();
CstString elementName = (CstString) pool.get(elementNameIndex);
if (observer != null) {
parsed(2, "element_name: " + elementName.toHuman());
parsed(0, "value: ");
changeIndent(1);
}
Constant value = parseValue();
if (observer != null) {
changeIndent(-1);
}
return new NameValuePair(elementName, value);
}
示例2: signature
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Parses a {@code Signature} attribute.
*/
private Attribute signature(DirectClassFile cf, int offset, int length,
ParseObserver observer) {
if (length != 2) {
throwBadLength(2);
}
ByteArray bytes = cf.getBytes();
ConstantPool pool = cf.getConstantPool();
int idx = bytes.getUnsignedShort(offset);
CstString cst = (CstString) pool.get(idx);
Attribute result = new AttSignature(cst);
if (observer != null) {
observer.parsed(bytes, offset, 2, "signature: " + cst);
}
return result;
}
示例3: if
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Interns the given constant in the appropriate section of this
* instance, or do nothing if the given constant isn't the sort
* that should be interned.
*
* @param cst {@code non-null;} constant to possibly intern
*/
/*package*/ void internIfAppropriate(Constant cst) {
if (cst instanceof CstString) {
stringIds.intern((CstString) cst);
} else if (cst instanceof CstType) {
typeIds.intern((CstType) cst);
} else if (cst instanceof CstBaseMethodRef) {
methodIds.intern((CstBaseMethodRef) cst);
} else if (cst instanceof CstFieldRef) {
fieldIds.intern((CstFieldRef) cst);
} else if (cst instanceof CstEnumRef) {
fieldIds.intern(((CstEnumRef) cst).getFieldRef());
} else if (cst == null) {
throw new NullPointerException("cst == null");
}
}
示例4: mergeDescriptorsAndSignatures
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Returns an instance which is the result of merging the two
* given instances, where one instance should have only type
* descriptors and the other only type signatures. The merged
* result is identical to the one with descriptors, except that
* any element whose {name, index, start, length} matches an
* element in the signature list gets augmented with the
* corresponding signature. The result is immutable.
*
* @param descriptorList {@code non-null;} list with descriptors
* @param signatureList {@code non-null;} list with signatures
* @return {@code non-null;} the merged result
*/
public static LocalVariableList mergeDescriptorsAndSignatures(
LocalVariableList descriptorList,
LocalVariableList signatureList) {
int descriptorSize = descriptorList.size();
LocalVariableList result = new LocalVariableList(descriptorSize);
for (int i = 0; i < descriptorSize; i++) {
Item item = descriptorList.get(i);
Item signatureItem = signatureList.itemToLocal(item);
if (signatureItem != null) {
CstString signature = signatureItem.getSignature();
item = item.withSignature(signature);
}
result.set(i, item);
}
result.setImmutable();
return result;
}
示例5: indexOf
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Gets the index of the given string, which must have been added
* to this instance.
*
* @param string {@code non-null;} the string to look up
* @return {@code >= 0;} the string's index
*/
public int indexOf(CstString string) {
if (string == null) {
throw new NullPointerException("string == null");
}
throwIfNotPrepared();
StringIdItem s = strings.get(string);
if (s == null) {
throw new IllegalArgumentException("not found");
}
return s.getIndex();
}
示例6: get
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
if (cst == null) {
throw new NullPointerException("cst == null");
}
throwIfNotPrepared();
IndexedItem result = strings.get((CstString) cst);
if (result == null) {
throw new IllegalArgumentException("not found");
}
return result;
}
示例7: AttConstantValue
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Constructs an instance.
*
* @param constantValue {@code non-null;} the constant value, which must
* be an instance of one of: {@code CstString},
* {@code CstInteger}, {@code CstLong},
* {@code CstFloat}, or {@code CstDouble}
*/
public AttConstantValue(TypedConstant constantValue) {
super(ATTRIBUTE_NAME);
if (!((constantValue instanceof CstString) ||
(constantValue instanceof CstInteger) ||
(constantValue instanceof CstLong) ||
(constantValue instanceof CstFloat) ||
(constantValue instanceof CstDouble))) {
if (constantValue == null) {
throw new NullPointerException("constantValue == null");
}
throw new IllegalArgumentException("bad type for constantValue");
}
this.constantValue = constantValue;
}
示例8: visitConstant
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/** {@inheritDoc} */
public void visitConstant(int opcode, int offset, int length,
Constant cst, int value) {
visitCommon(offset, length, true);
if ((cst instanceof CstMemberRef) || (cst instanceof CstType) ||
(cst instanceof CstString)) {
/*
* Instructions with these sorts of constants have the
* possibility of throwing, so this instruction needs to
* end its block (since it can throw, and possible-throws
* are branch points).
*/
visitThrowing(offset, length, true);
}
}
示例9: ClassDefItem
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Constructs an instance. Its sets of members and annotations are
* initially empty.
*
* @param thisClass {@code non-null;} type constant for this class
* @param accessFlags access flags
* @param superclass {@code null-ok;} superclass or {@code null} if
* this class is a/the root class
* @param interfaces {@code non-null;} list of implemented interfaces
* @param sourceFile {@code null-ok;} source file name or
* {@code null} if unknown
*/
public ClassDefItem(CstType thisClass, int accessFlags,
CstType superclass, TypeList interfaces, CstString sourceFile) {
if (thisClass == null) {
throw new NullPointerException("thisClass == null");
}
/*
* TODO: Maybe check accessFlags and superclass, at
* least for easily-checked stuff?
*/
if (interfaces == null) {
throw new NullPointerException("interfaces == null");
}
this.thisClass = thisClass;
this.accessFlags = accessFlags;
this.superclass = superclass;
this.interfaces =
(interfaces.size() == 0) ? null : new TypeListItem(interfaces);
this.sourceFile = sourceFile;
this.classData = new ClassDataItem(thisClass);
this.staticValuesItem = null;
this.annotationsDirectory = new AnnotationsDirectoryItem();
}
示例10: addConstants
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Helper for {@link #getAllConstants} which adds all the info for
* a single {@code RegisterSpec}.
*
* @param result {@code non-null;} result set to add to
* @param spec {@code null-ok;} register spec to add
*/
private static void addConstants(HashSet<Constant> result,
RegisterSpec spec) {
if (spec == null) {
return;
}
LocalItem local = spec.getLocalItem();
CstString name = local.getName();
CstString signature = local.getSignature();
Type type = spec.getType();
if (type != Type.KNOWN_NULL) {
result.add(CstType.intern(type));
}
if (name != null) {
result.add(name);
}
if (signature != null) {
result.add(signature);
}
}
示例11: intern
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Interns an element into this instance.
*
* @param string {@code non-null;} the string to intern
* @return {@code non-null;} the interned string
*/
public synchronized StringIdItem intern(StringIdItem string) {
if (string == null) {
throw new NullPointerException("string == null");
}
throwIfPrepared();
CstString value = string.getValue();
StringIdItem already = strings.get(value);
if (already != null) {
return already;
}
strings.put(value, string);
return string;
}
示例12: sourceFile
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Parses a {@code SourceFile} attribute.
*/
private Attribute sourceFile(DirectClassFile cf, int offset, int length,
ParseObserver observer) {
if (length != 2) {
throwBadLength(2);
}
ByteArray bytes = cf.getBytes();
ConstantPool pool = cf.getConstantPool();
int idx = bytes.getUnsignedShort(offset);
CstString cst = (CstString) pool.get(idx);
Attribute result = new AttSourceFile(cst);
if (observer != null) {
observer.parsed(bytes, offset, 2, "source: " + cst);
}
return result;
}
示例13: add
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Add an element to the set of (name, value) pairs for this instance.
* It is an error to call this method if there is a preexisting element
* with the same name.
*
* @param pair {@code non-null;} the (name, value) pair to add to this instance
*/
public void add(NameValuePair pair) {
throwIfImmutable();
if (pair == null) {
throw new NullPointerException("pair == null");
}
CstString name = pair.getName();
if (elements.get(name) != null) {
throw new IllegalArgumentException("name already added: " + name);
}
elements.put(name, pair);
}
示例14: entryAnnotationString
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Returns a string representation of this LocalList entry that is
* appropriate for emitting as an annotation.
*
* @param e {@code non-null;} entry
* @return {@code non-null;} annotation string
*/
private String entryAnnotationString(LocalList.Entry e) {
StringBuilder sb = new StringBuilder();
sb.append(RegisterSpec.PREFIX);
sb.append(e.getRegister());
sb.append(' ');
CstString name = e.getName();
if (name == null) {
sb.append("null");
} else {
sb.append(name.toHuman());
}
sb.append(' ');
CstType type = e.getType();
if (type == null) {
sb.append("null");
} else {
sb.append(type.toHuman());
}
CstString signature = e.getSignature();
if (signature != null) {
sb.append(' ');
sb.append(signature.toHuman());
}
return sb.toString();
}
示例15: parseAnnotation
import com.android.dx.rop.cst.CstString; //导入依赖的package包/类
/**
* Parses a single annotation.
*
* @param visibility {@code non-null;} visibility of the parsed annotation
* @return {@code non-null;} the parsed annotation
*/
private Annotation parseAnnotation(AnnotationVisibility visibility)
throws IOException {
requireLength(4);
int typeIndex = input.readUnsignedShort();
int numElements = input.readUnsignedShort();
CstString typeString = (CstString) pool.get(typeIndex);
CstType type = new CstType(Type.intern(typeString.getString()));
if (observer != null) {
parsed(2, "type: " + type.toHuman());
parsed(2, "num_elements: " + numElements);
}
Annotation annotation = new Annotation(type, visibility);
for (int i = 0; i < numElements; i++) {
if (observer != null) {
parsed(0, "elements[" + i + "]:");
changeIndent(1);
}
NameValuePair element = parseElement();
annotation.add(element);
if (observer != null) {
changeIndent(-1);
}
}
annotation.setImmutable();
return annotation;
}