KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > config > Root


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.config;
5
6
7 public class Root {
8   private final static byte DSO_FINAL_NOT_SET = 0x01;
9   private final static byte NOT_DSO_FINAL = 0x02;
10   private final static byte DSO_FINAL = 0x03;
11
12   private final String JavaDoc className;
13   private final String JavaDoc fieldName;
14   private final String JavaDoc rootName;
15   private final byte dsoFinal;
16
17   public Root(String JavaDoc className, String JavaDoc fieldName, String JavaDoc rootName) {
18     this.className = className;
19     this.fieldName = fieldName;
20     this.rootName = rootName;
21     this.dsoFinal = DSO_FINAL_NOT_SET;
22   }
23
24   public Root(String JavaDoc className, String JavaDoc fieldName, String JavaDoc rootName, boolean dsoFinal) {
25     this.className = className;
26     this.fieldName = fieldName;
27     this.rootName = rootName;
28     this.dsoFinal = dsoFinal? DSO_FINAL : NOT_DSO_FINAL;
29   }
30
31   public boolean matches(String JavaDoc matchClassName, String JavaDoc matchFieldName) {
32     return className.equals(matchClassName) && fieldName.equals(matchFieldName);
33   }
34
35   public String JavaDoc getClassName() {
36     return this.className;
37   }
38
39   public String JavaDoc getFieldName() {
40     return this.fieldName;
41   }
42
43   public String JavaDoc getRootName() {
44     return this.rootName == null ? className + "." + fieldName : rootName;
45   }
46   
47   public boolean isDsoFinal(boolean isPrimitive) {
48     if (dsoFinal != DSO_FINAL_NOT_SET) {
49       return (dsoFinal == DSO_FINAL);
50     } else {
51       return !isPrimitive;
52     }
53   }
54
55   private boolean isDsoFinal() {
56     return (dsoFinal == DSO_FINAL);
57   }
58
59   public String JavaDoc toString() {
60     return getClass().getName() + "[className=" + getClassName() + ", fieldName=" + getFieldName() + ", rootName="
61            + getRootName() + ", dsoFinal=" + isDsoFinal() + "]";
62   }
63 }
Popular Tags