1 23 package com.sun.enterprise.deployment; 24 25 import java.lang.reflect.Field ; 26 27 34 35 public class FieldDescriptor extends Descriptor { 36 37 40 public FieldDescriptor() { 41 } 42 43 46 public FieldDescriptor(String name) { 47 super(name, "no description"); 48 } 49 50 53 public FieldDescriptor(String name, String description) { 54 super(name, description); 55 } 56 57 60 61 public FieldDescriptor(Field field) { 62 this(field.getName(), "no description"); 63 } 64 65 67 68 public boolean equals(Object object) { 69 if (object instanceof FieldDescriptor) { 70 FieldDescriptor otherFieldDescriptor = (FieldDescriptor) object; 71 return otherFieldDescriptor.getName().equals(this.getName()); 72 } 73 return false; 74 } 75 76 78 79 public int hashCode() { 80 return this.getName().hashCode(); 81 } 82 83 86 87 public void print(StringBuffer toStringBuffer) { 88 toStringBuffer.append("Field: ").append(super.getName()).append("@").append(super.getDescription()); 89 } 90 91 99 public static void checkFieldName(String fieldName) throws IllegalArgumentException { 100 101 if (fieldName == null || fieldName.length()==0) { 102 throw new IllegalArgumentException ("cmp-field or cmr-field name cannot be empty strings"); 103 } 104 char firstChar = fieldName.charAt(0); 105 if (!Character.isLetter(firstChar)) { 106 throw new IllegalArgumentException ("cmp-field or cmr-field name " + fieldName + " must begin with a letter "); 107 } 108 if (!Character.isLowerCase(firstChar)) { 109 throw new IllegalArgumentException ("cmp-field or cmr-field name " + fieldName + " must begin with a lowercase letter"); 110 } 111 } 112 } 113 | Popular Tags |