#Java - Code Snippets for '#.Constant' - 17 code snippet(s) found |
|
Sample 1. Code Sample / Example / Snippet of org.apache.bcel.generic.ConstantPoolGen | |
|
public void testCreateIntegerElementValue() throws Exception
{
final ClassGen cg = createClassGen("HelloWorld");
final ConstantPoolGen cp = cg.getConstantPool();
final SimpleElementValueGen evg = new SimpleElementValueGen(
ElementValueGen.PRIMITIVE_INT, cp, 555);
assertTrue("Should have the same index in the constantpool but "
+ evg.getIndex() + "!=" + cp.lookupInteger(555),
evg.getIndex() == cp.lookupInteger(555));
checkSerialize(evg, cp);
}
|
|
Like Feedback org.apache.bcel.generic.ConstantPoolGen |
|
|
Sample 2. Code Sample / Example / Snippet of static org.apache.ace.it.deployment.Constants.TEST_TARGETID | |
|
public interface Constants {
String TEST_AUTH_SCHEME = "<roles><group name="TestGroup"><properties><type>userGroup</type></properties></group>"
+ "<user name="d"><properties><username>d</username></properties><credentials>"
+ "<password>f</password></credentials><memberof>TestGroup</memberof></user></roles>";
String TEST_CUSTOMER = "apache";
int TEST_HTTP_PORT = TestConstants.PORT;
String TEST_TARGETID = "test-target";
}
|
|
Like Feedback static org.apache.ace.it.deployment.Constants.TEST_TARGETID |
|
|
Sample 3. Code Sample / Example / Snippet of static org.apache.ace.it.deployment.Constants.TEST_CUSTOMER | |
|
public interface Constants {
String TEST_AUTH_SCHEME = "<roles><group name="TestGroup"><properties><type>userGroup</type></properties></group>"
+ "<user name="d"><properties><username>d</username></properties><credentials>"
+ "<password>f</password></credentials><memberof>TestGroup</memberof></user></roles>";
String TEST_CUSTOMER = "apache";
int TEST_HTTP_PORT = TestConstants.PORT;
String TEST_TARGETID = "test-target";
}
|
|
Like Feedback static org.apache.ace.it.deployment.Constants.TEST_CUSTOMER |
|
|
Sample 4. Code Sample / Example / Snippet of static org.apache.ace.it.deployment.Constants.TEST_HTTP_PORT | |
|
public interface Constants {
String TEST_AUTH_SCHEME = "<roles><group name="TestGroup"><properties><type>userGroup</type></properties></group>"
+ "<user name="d"><properties><username>d</username></properties><credentials>"
+ "<password>f</password></credentials><memberof>TestGroup</memberof></user></roles>";
String TEST_CUSTOMER = "apache";
int TEST_HTTP_PORT = TestConstants.PORT;
String TEST_TARGETID = "test-target";
}
|
|
Like Feedback static org.apache.ace.it.deployment.Constants.TEST_HTTP_PORT |
|
|
|
Sample 5. Code Sample / Example / Snippet of static org.apache.ace.it.deployment.Constants.TEST_AUTH_SCHEME | |
|
public interface Constants {
String TEST_AUTH_SCHEME = "<roles><group name="TestGroup"><properties><type>userGroup</type></properties></group>"
+ "<user name="d"><properties><username>d</username></properties><credentials>"
+ "<password>f</password></credentials><memberof>TestGroup</memberof></user></roles>";
String TEST_CUSTOMER = "apache";
int TEST_HTTP_PORT = TestConstants.PORT;
String TEST_TARGETID = "test-target";
}
|
|
Like Feedback static org.apache.ace.it.deployment.Constants.TEST_AUTH_SCHEME |
|
|
Sample 6. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantPool | |
|
public void testCheckMethodLevelNamedInnerClass()
throws ClassNotFoundException
{
final JavaClass clazz = getTestClass(PACKAGE_BASE_NAME+".data.AttributeTestClassEM01$1S");
final ConstantPool pool = clazz.getConstantPool();
final Attribute[] encMethodAttrs = findAttribute("EnclosingMethod", clazz);
assertTrue("Expected 1 EnclosingMethod attribute but found "
+ encMethodAttrs.length, encMethodAttrs.length == 1);
final EnclosingMethod em = (EnclosingMethod) encMethodAttrs[0];
final String enclosingClassName = em.getEnclosingClass().getBytes(pool);
final String enclosingMethodName = em.getEnclosingMethod().getName(pool);
assertTrue(
"Expected class name to be '"+PACKAGE_BASE_SIG+"/data/AttributeTestClassEM01' but was "
+ enclosingClassName, enclosingClassName
.equals(PACKAGE_BASE_SIG+"/data/AttributeTestClassEM01"));
assertTrue("Expected method name to be 'main' but was "
+ enclosingMethodName, enclosingMethodName.equals("main"));
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantPool |
|
|
Sample 7. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantUtf8 | |
|
public static String[] getClassDependencies(ConstantPool pool) {
String[] tempArray = new String[pool.getLength()];
int size = 0;
StringBuilder buf = new StringBuilder();
for (int idx = 0; idx < pool.getLength(); idx++) {
Constant c = pool.getConstant(idx);
if (c != null && c.getTag() == Constants.CONSTANT_Class) {
ConstantUtf8 c1 = (ConstantUtf8) pool.getConstant(((ConstantClass) c).getNameIndex());
buf.setLength(0);
buf.append(c1.getBytes());
for (int n = 0; n < buf.length(); n++) {
if (buf.charAt(n) == '/') {
buf.setCharAt(n, '.');
}
}
tempArray[size++] = buf.toString();
}
}
String[] dependencies = new String[size];
System.arraycopy(tempArray, 0, dependencies, 0, size);
return dependencies;
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantUtf8 |
|
|
Sample 8. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantNameAndType | |
|
private void visitRef(ConstantCP ccp, boolean method) {
String class_name = ccp.getClass(cp);
add(class_name);
ConstantNameAndType cnat = (ConstantNameAndType) cp.getConstant(ccp.getNameAndTypeIndex(),
Constants.CONSTANT_NameAndType);
String signature = cnat.getSignature(cp);
if (method) {
Type type = Type.getReturnType(signature);
checkType(type);
for (Type type1 : Type.getArgumentTypes(signature)) {
checkType(type1);
}
} else {
checkType(Type.getType(signature));
}
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantNameAndType |
|
|
Sample 9. Code Sample / Example / Snippet of org.apache.bcel.classfile.Constant | |
|
public String getEnumTypeString()
{
return ((ConstantUtf8) getConstantPool().getConstant(typeIdx))
.getBytes();
}
|
|
Like Feedback org.apache.bcel.classfile.Constant |
|
|
|
Sample 10. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantInteger | |
|
public int getValueInt()
{
if (super.getElementValueType() != PRIMITIVE_INT) {
throw new RuntimeException(
"Dont call getValueString() on a non STRING ElementValue");
}
final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx);
return c.getBytes();
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantInteger |
|
|
Sample 11. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantClass | |
|
public String getEnumTypeString()
{
return ((ConstantUtf8) getConstantPool().getConstant(typeIdx))
.getBytes();
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantClass |
|
|
Sample 12. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantCP | |
|
public String getClassName( final ConstantPoolGen cpg ) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantCP cmr = (ConstantCP) cp.getConstant(super.getIndex());
final String className = cp.getConstantString(cmr.getClassIndex(), Const.CONSTANT_Class);
if (className.startsWith("[")) {
return "java.lang.Object";
}
return className.replace('/', '.');
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantCP |
|
|
Sample 13. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantFloat | |
|
public int lookupFloat( final float n ) {
final int bits = Float.floatToIntBits(n);
for (int i = 1; i < index; i++) {
if (constants[i] instanceof ConstantFloat) {
final ConstantFloat c = (ConstantFloat) constants[i];
if (Float.floatToIntBits(c.getBytes()) == bits) {
return i;
}
}
}
return -1;
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantFloat |
|
|
Sample 14. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantString | |
|
public String stringifyValue()
{
final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx);
return cu8.getBytes();
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantString |
|
|
|
Sample 15. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantLong | |
|
public int lookupLong( final long n ) {
for (int i = 1; i < index; i++) {
if (constants[i] instanceof ConstantLong) {
final ConstantLong c = (ConstantLong) constants[i];
if (c.getBytes() == n) {
return i;
}
}
}
return -1;
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantLong |
|
|
Sample 16. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantDouble | |
|
public int lookupDouble( final double n ) {
final long bits = Double.doubleToLongBits(n);
for (int i = 1; i < index; i++) {
if (constants[i] instanceof ConstantDouble) {
final ConstantDouble c = (ConstantDouble) constants[i];
if (Double.doubleToLongBits(c.getBytes()) == bits) {
return i;
}
}
}
return -1;
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantDouble |
|
|
Sample 17. Code Sample / Example / Snippet of org.apache.bcel.classfile.ConstantValue | |
|
public void visitField( final Field field ) {
_out.println();
_out.println(" field = new FieldGen(" + printFlags(field.getAccessFlags()) + ", "
+ printType(field.getSignature()) + ", "" + field.getName() + "", _cp);");
final ConstantValue cv = field.getConstantValue();
if (cv != null) {
final String value = cv.toString();
_out.println(" field.setInitValue(" + value + ")");
}
_out.println(" _cg.addField(field.getField());");
}
|
|
Like Feedback org.apache.bcel.classfile.ConstantValue |
|
|