01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: ParsedBlockValue.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.template;
09:
10: import com.uwyn.rife.asm.ClassVisitor;
11: import com.uwyn.rife.asm.MethodVisitor;
12: import com.uwyn.rife.template.ParsedBlockPart;
13:
14: public class ParsedBlockValue extends ParsedBlockPart {
15: private String mValueKey = null;
16: private String mValueTag = null;
17:
18: ParsedBlockValue(String valueKey, String valueTag) {
19: assert valueKey != null;
20: assert valueKey.length() > 0;
21: assert valueTag != null;
22: assert valueTag.length() > 0;
23:
24: mValueKey = valueKey;
25: mValueTag = valueTag;
26: }
27:
28: String getData() {
29: return mValueKey;
30: }
31:
32: String getTag() {
33: return mValueTag;
34: }
35:
36: int getType() {
37: return VALUE;
38: }
39:
40: void visitByteCodeExternalForm(MethodVisitor visitor,
41: String className, String staticIdentifier) {
42: visitor.visitVarInsn(ALOAD, 0);
43: visitor.visitFieldInsn(GETSTATIC, className, staticIdentifier,
44: "Ljava/lang/String;");
45: visitor.visitFieldInsn(GETSTATIC, className, staticIdentifier
46: + "Tag", "Ljava/lang/String;");
47: visitor.visitVarInsn(ALOAD, 2);
48: visitor
49: .visitMethodInsn(INVOKEVIRTUAL, className,
50: "appendValueExternalForm",
51: "(Ljava/lang/String;Ljava/lang/String;Lcom/uwyn/rife/template/ExternalValue;)V");
52: }
53:
54: void visitByteCodeInternalForm(MethodVisitor visitor,
55: String className, String staticIdentifier) {
56: visitor.visitVarInsn(ALOAD, 0);
57: visitor.visitFieldInsn(GETSTATIC, className, staticIdentifier,
58: "Ljava/lang/String;");
59: visitor.visitFieldInsn(GETSTATIC, className, staticIdentifier
60: + "Tag", "Ljava/lang/String;");
61: visitor.visitVarInsn(ALOAD, 2);
62: visitor
63: .visitMethodInsn(INVOKEVIRTUAL, className,
64: "appendValueInternalForm",
65: "(Ljava/lang/String;Ljava/lang/String;Lcom/uwyn/rife/template/InternalValue;)V");
66: }
67:
68: void visitByteCodeStaticDeclaration(ClassVisitor visitor,
69: String staticIdentifier) {
70: visitor.visitField(ACC_PRIVATE | ACC_STATIC, staticIdentifier,
71: "Ljava/lang/String;", null, null);
72: visitor.visitField(ACC_PRIVATE | ACC_STATIC, staticIdentifier
73: + "Tag", "Ljava/lang/String;", null, null);
74: }
75:
76: void visitByteCodeStaticDefinition(MethodVisitor visitor,
77: String className, String staticIdentifier) {
78: visitor.visitLdcInsn(mValueKey);
79: visitor.visitFieldInsn(PUTSTATIC, className, staticIdentifier,
80: "Ljava/lang/String;");
81: visitor.visitLdcInsn(mValueTag);
82: visitor.visitFieldInsn(PUTSTATIC, className, staticIdentifier
83: + "Tag", "Ljava/lang/String;");
84: }
85: }
|