Class FieldEditor
java.lang.Object
EDU.purdue.cs.bloat.editor.FieldEditor
FieldEditor provides a means to edit a field of a class. A
FieldEditor is created from a ClassEditor and a
reflect.FieldInfo. A FieldEditor knows its name, type
(descriptor), and its constant value (if it has one).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFieldEditor(ClassEditor editor, int modifiers, Type type, String name) Creates a newFieldEditorfor editing a field in a given class with the given modifiers, type and nameFieldEditor(ClassEditor editor, int modifiers, Type type, String name, Object constantValue) Creates a newFieldEditorfor editing a field in a given class with the given modifiers, type, name, and constant value.FieldEditor(ClassEditor editor, int modifiers, Class type, String name) FieldEditor(ClassEditor editor, int modifiers, Class type, String name, Object constantValue) FieldEditor(ClassEditor editor, FieldInfo fieldInfo) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()Commit changes to the field back to the ClassEditor.Returns the ClassEditor used to edit the class in which this field resides.voiddelete()Marks this field for deletion.Returns the raw FieldInfo of the field being edited.fullName()Returns a String that contains the declaring class name and the name of the fieldbooleanisDirty()Returns true if this field has been modified.booleanisFinal()booleanReturns true, if the field has package level visibility.booleanbooleanbooleanisPublic()booleanisStatic()booleanbooleanReturns aMemberReffor the fieldname()Returns the name of the field.Returns a NameAndType of the field.voidprint(PrintStream out) Print the field.voidsetDirty(boolean isDirty) Sets the dirty flag of this method.voidsetFinal(boolean flag) voidsetPrivate(boolean flag) voidsetProtected(boolean flag) voidsetPublic(boolean flag) voidsetStatic(boolean flag) voidsetTransient(boolean flag) voidsetVolatile(boolean flag) toString()type()Returns the type of the field.
-
Constructor Details
-
FieldEditor
Creates a newFieldEditorfor editing a field in a given class with the given modifiers, type and name- Throws:
IllegalArgumentException- If a field with the desired name already exists in the class
-
FieldEditor
public FieldEditor(ClassEditor editor, int modifiers, Class type, String name, Object constantValue) -
FieldEditor
-
FieldEditor
Creates a newFieldEditorfor editing a field in a given class with the given modifiers, type, name, and constant value.- Parameters:
modifiers- Fields that have a constant value must bestaticandfinal- Throws:
IllegalArgumentException- If a field with the desired name already exists in the class or ifconstantValueis non-null and neither aString,Integer,Long,Float, norDouble.
-
FieldEditor
Constructor.- Parameters:
editor- The class containing the field.fieldInfo- The field to edit.- See Also:
-
-
Method Details
-
declaringClass
Returns the ClassEditor used to edit the class in which this field resides. -
isDirty
public boolean isDirty()Returns true if this field has been modified. -
setDirty
public void setDirty(boolean isDirty) Sets the dirty flag of this method. The dirty flag is true if the method has been modified.- Throws:
IllegalStateException- This field has been marked for deletion
-
delete
public void delete()Marks this field for deletion. Once a field has been marked for deletion all attempts to change it will throw anIllegalStateException. -
fieldInfo
Returns the raw FieldInfo of the field being edited. -
constantValue
-
isPublic
public boolean isPublic() -
isPrivate
public boolean isPrivate() -
isProtected
public boolean isProtected() -
isPackage
public boolean isPackage()Returns true, if the field has package level visibility. -
isStatic
public boolean isStatic() -
isFinal
public boolean isFinal() -
isVolatile
public boolean isVolatile() -
isTransient
public boolean isTransient() -
setPublic
public void setPublic(boolean flag) - Throws:
IllegalStateException- This field has been marked for deletion
-
setPrivate
public void setPrivate(boolean flag) - Throws:
IllegalStateException- This field has been marked for deletion
-
setProtected
public void setProtected(boolean flag) - Throws:
IllegalStateException- This field has been marked for deletion
-
setStatic
public void setStatic(boolean flag) - Throws:
IllegalStateException- This field has been marked for deletion
-
setFinal
public void setFinal(boolean flag) - Throws:
IllegalStateException- This field has been marked for deletion
-
setTransient
public void setTransient(boolean flag) - Throws:
IllegalStateException- This field has been marked for deletion
-
setVolatile
public void setVolatile(boolean flag) - Throws:
IllegalStateException- This field has been marked for deletion
-
name
Returns the name of the field. -
type
Returns the type of the field. -
nameAndType
Returns a NameAndType of the field. -
memberRef
Returns aMemberReffor the field -
commit
public void commit()Commit changes to the field back to the ClassEditor. Note that the field is committed regardless of whether or not it is dirty. -
print
-
fullName
Returns a String that contains the declaring class name and the name of the field -
toString
-