1 16 19 package com.sun.org.apache.xml.internal.utils.synthetic.reflection; 20 21 import com.sun.org.apache.xml.internal.utils.synthetic.Class; 22 import com.sun.org.apache.xml.internal.utils.synthetic.SynthesisException; 23 24 36 public class Field extends Object implements Member 37 { 38 39 40 public String name, initializer = null; 41 42 43 int modifiers; 44 45 46 java.lang.reflect.Field realfield = null; 47 48 49 Class declaringClass, type; 50 51 57 public Field(java.lang.reflect.Field realfield, 58 com.sun.org.apache.xml.internal.utils.synthetic.Class declaringClass) 59 { 60 61 this(realfield.getName(), declaringClass); 62 63 this.realfield = realfield; 64 this.type = 65 com.sun.org.apache.xml.internal.utils.synthetic.Class.forClass(realfield.getType()); 66 } 67 68 74 public Field(String name, 75 com.sun.org.apache.xml.internal.utils.synthetic.Class declaringClass) 76 { 77 this.name = name; 78 this.declaringClass = declaringClass; 79 } 80 81 90 public boolean equals(Object obj) 91 { 92 93 if (realfield != null) 94 return realfield.equals(obj); 95 else if (obj instanceof Field) 96 { 97 Field objf = (Field) obj; 98 99 return (declaringClass.equals(objf.declaringClass) 100 && name.equals(objf.name) && type.equals(objf.type)); 101 } 102 else 103 return false; 104 } 105 106 146 public Object get(Object obj) 147 throws IllegalArgumentException , IllegalAccessException 148 { 149 150 if (realfield != null) 151 return realfield.get(obj); 152 153 throw new java.lang.IllegalStateException (); 154 } 155 156 169 public boolean getBoolean(Object obj) 170 throws IllegalArgumentException , IllegalAccessException 171 { 172 173 if (realfield != null) 174 return realfield.getBoolean(obj); 175 176 throw new java.lang.IllegalStateException (); 177 } 178 179 192 public byte getByte(Object obj) 193 throws IllegalArgumentException , IllegalAccessException 194 { 195 196 if (realfield != null) 197 return realfield.getByte(obj); 198 199 throw new java.lang.IllegalStateException (); 200 } 201 202 215 public char getChar(Object obj) 216 throws IllegalArgumentException , IllegalAccessException 217 { 218 219 if (realfield != null) 220 return realfield.getChar(obj); 221 222 throw new java.lang.IllegalStateException (); 223 } 224 225 231 public com.sun.org.apache.xml.internal.utils.synthetic.Class getDeclaringClass() 232 { 233 234 if (realfield != null) 235 return com.sun.org.apache.xml.internal.utils.synthetic.Class.forClass( 236 realfield.getDeclaringClass()); 237 238 throw new java.lang.IllegalStateException (); 239 } 240 241 254 public double getDouble(Object obj) 255 throws IllegalArgumentException , IllegalAccessException 256 { 257 258 if (realfield != null) 259 return realfield.getDouble(obj); 260 261 throw new java.lang.IllegalStateException (); 262 } 263 264 277 public float getFloat(Object obj) 278 throws IllegalArgumentException , IllegalAccessException 279 { 280 281 if (realfield != null) 282 return realfield.getFloat(obj); 283 284 throw new java.lang.IllegalStateException (); 285 } 286 287 299 public int getInt(Object obj) 300 throws IllegalArgumentException , IllegalAccessException 301 { 302 303 if (realfield != null) 304 return realfield.getInt(obj); 305 306 throw new java.lang.IllegalStateException (); 307 } 308 309 322 public long getLong(Object obj) 323 throws IllegalArgumentException , IllegalAccessException 324 { 325 326 if (realfield != null) 327 return realfield.getLong(obj); 328 329 throw new java.lang.IllegalStateException (); 330 } 331 332 339 public int getModifiers() 340 { 341 342 if (realfield != null) 343 modifiers = realfield.getModifiers(); 344 345 return modifiers; 346 } 347 348 354 public String getInitializer() 355 { 356 return initializer; 357 } 358 359 367 public void setInitializer(String i) throws SynthesisException 368 { 369 370 if (realfield != null) 371 throw new SynthesisException(SynthesisException.REIFIED); 372 373 initializer = i; 374 } 375 376 381 public java.lang.String getName() 382 { 383 return name; 384 } 385 386 399 public short getShort(Object obj) 400 throws IllegalArgumentException , IllegalAccessException 401 { 402 403 if (realfield != null) 404 return realfield.getShort(obj); 405 406 throw new java.lang.IllegalStateException (); 407 } 408 409 414 public Class getType() 415 { 416 417 if (realfield != null) 418 type = Class.forClass(realfield.getType()); 419 420 return type; 421 } 422 423 431 public void setType(com.sun.org.apache.xml.internal.utils.synthetic.Class type) 432 throws SynthesisException 433 { 434 435 if (realfield != null) 436 throw new SynthesisException(SynthesisException.REIFIED); 437 438 this.type = type; 439 } 440 441 448 public int hashCode() 449 { 450 451 if (realfield != null) 452 return realfield.hashCode(); 453 else 454 return declaringClass.getName().hashCode() ^ name.hashCode(); 455 } 456 457 509 public void set(Object obj, Object value) 510 throws IllegalArgumentException , IllegalAccessException 511 { 512 513 if (realfield != null) 514 realfield.set(obj, value); 515 516 throw new java.lang.IllegalStateException (); 517 } 518 519 534 public void setBoolean(Object obj, boolean z) 535 throws IllegalArgumentException , IllegalAccessException 536 { 537 538 if (realfield != null) 539 realfield.setBoolean(obj, z); 540 541 throw new java.lang.IllegalStateException (); 542 } 543 544 559 public void setByte(Object obj, byte b) 560 throws IllegalArgumentException , IllegalAccessException 561 { 562 563 if (realfield != null) 564 realfield.setByte(obj, b); 565 566 throw new java.lang.IllegalStateException (); 567 } 568 569 584 public void setChar(Object obj, char c) 585 throws IllegalArgumentException , IllegalAccessException 586 { 587 588 if (realfield != null) 589 realfield.setChar(obj, c); 590 591 throw new java.lang.IllegalStateException (); 592 } 593 594 601 public void setDeclaringClass( 602 com.sun.org.apache.xml.internal.utils.synthetic.Class declaringClass) 603 { 604 this.declaringClass = declaringClass; 605 } 606 607 622 public void setDouble(Object obj, double d) 623 throws IllegalArgumentException , IllegalAccessException 624 { 625 626 if (realfield != null) 627 realfield.setDouble(obj, d); 628 629 throw new java.lang.IllegalStateException (); 630 } 631 632 647 public void setFloat(Object obj, float f) 648 throws IllegalArgumentException , IllegalAccessException 649 { 650 651 if (realfield != null) 652 realfield.setFloat(obj, f); 653 654 throw new java.lang.IllegalStateException (); 655 } 656 657 672 public void setInt(Object obj, int i) 673 throws IllegalArgumentException , IllegalAccessException 674 { 675 676 if (realfield != null) 677 realfield.setInt(obj, i); 678 679 throw new java.lang.IllegalStateException (); 680 } 681 682 697 public void setLong(Object obj, long l) 698 throws IllegalArgumentException , IllegalAccessException 699 { 700 701 if (realfield != null) 702 realfield.setLong(obj, l); 703 704 throw new java.lang.IllegalStateException (); 705 } 706 707 715 public void setModifiers(int modifiers) throws SynthesisException 716 { 717 718 if (realfield != null) 719 throw new SynthesisException(SynthesisException.REIFIED); 720 721 this.modifiers = modifiers; 722 } 723 724 739 public void setShort(Object obj, short s) 740 throws IllegalArgumentException , IllegalAccessException 741 { 742 743 if (realfield != null) 744 realfield.setShort(obj, s); 745 746 throw new java.lang.IllegalStateException (); 747 } 748 749 768 public String toString() 769 { 770 771 if (realfield != null) 772 return realfield.toString(); 773 774 throw new java.lang.IllegalStateException (); 775 } 776 777 781 public String toSource() 782 { 783 784 StringBuffer sb = new StringBuffer ( 785 java.lang.reflect.Modifier.toString(getModifiers())).append(' ').append( 786 getType().getJavaName()).append(' ').append(getName()); 787 String i = getInitializer(); 788 789 if (i != null && i.length() > 0) 790 sb.append('=').append(i); 791 792 sb.append(';'); 793 794 return sb.toString(); 795 } 796 } 797 | Popular Tags |