// SomeType cannot be boolean public void setProp( SomeType x ); public SomeType getProp( );or:
// type must be boolean public void setProp( boolean x ); public boolean isProp( );For example, class java.awt.Component has many properties, including:
PROPERTY NAME TYPE background java.awt.Color enabled boolean location java.awt.PointThe derived class java.awt.Container has all those properties plus also, among others:
PROPERTY NAME TYPE font java.awt.Font layout java.awt.LayoutManager
package cop4338;
public class Utilities
{
public static java.util.Map getProperties( Class cl )
{ ... }
public static java.util.Map getPropertyVals( Object obj )
{ ... }
}
The getProperties method returns a Map that stores the properties (as defined above) of Class cl. In the map that is returned, the keys are Strings (each of which represents a property name) and the values are Class objects (each of which represents the corresponding property type).
The getPropertyVals method returns a Map that stores the current value of the properties (as defined above) of Object obj. In the map that is returned, the keys are Strings (each of which represents a property name) and the values are of type Object each of which represents the current value of the corresponding property type. You can get the value by invoking the appropriate get method (using the invoke method of class Method. Needless to say, you should invoke getProperties as part of your implementation of getPropertyVals. Under no circumstances may either method produce any output at all, and you will receive a huge deduction if you violate this requirement.
Next, create an object of type java.util.Date and invoke getPropertyVals on it, outputting the state of the Date object's properties. If you are careful, the routine that traverses the Map (written above) can be reused.
Finally, you should write a class that you will pass as a parameter to getProperties to show that getProperties correctly:
You will receive a huge deduction if you violate the submission requirements.
PROPERTIES of javax.swing.JButton.class ======================================= Action interface javax.swing.Action ActionCommand class java.lang.String ActionMap class javax.swing.ActionMap AlignmentX float AlignmentY float Background class java.awt.Color Border interface javax.swing.border.Border BorderPainted boolean Bounds class java.awt.Rectangle ComponentOrientation class java.awt.ComponentOrientation ContentAreaFilled boolean Cursor class java.awt.Cursor DebugGraphicsOptions int DefaultCapable boolean DisabledIcon interface javax.swing.Icon DisabledSelectedIcon interface javax.swing.Icon DoubleBuffered boolean DropTarget class java.awt.dnd.DropTarget Enabled boolean FocusPainted boolean Font class java.awt.Font Foreground class java.awt.Color HorizontalAlignment int HorizontalTextPosition int Icon interface javax.swing.Icon InputVerifier class javax.swing.InputVerifier Label class java.lang.String Layout interface java.awt.LayoutManager Locale class java.util.Locale Location class java.awt.Point Margin class java.awt.Insets MaximumSize class java.awt.Dimension MinimumSize class java.awt.Dimension Mnemonic int Model interface javax.swing.ButtonModel Name class java.lang.String NextFocusableComponent class java.awt.Component Opaque boolean PreferredSize class java.awt.Dimension PressedIcon interface javax.swing.Icon RequestFocusEnabled boolean RolloverEnabled boolean RolloverIcon interface javax.swing.Icon RolloverSelectedIcon interface javax.swing.Icon Selected boolean SelectedIcon interface javax.swing.Icon Size class java.awt.Dimension Text class java.lang.String ToolTipText class java.lang.String UI class javax.swing.plaf.ButtonUI VerticalAlignment int VerticalTextPosition int Visible boolean VALUES of new javax.swing.JButton( ) ==================================== Action null ActionCommand "" ActionMap javax.swing.ActionMap@3d0dd4 AlignmentX 0.0 AlignmentY 0.5 Background javax.swing.plaf.ColorUIResource[r=204,g=204,b=204] Border javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@35f53a BorderPainted true Bounds java.awt.Rectangle[x=0,y=0,width=0,height=0] ComponentOrientation java.awt.ComponentOrientation@76f0bf ContentAreaFilled true Cursor java.awt.Cursor[Default Cursor] DebugGraphicsOptions 0 DefaultCapable true DisabledIcon null DisabledSelectedIcon null DoubleBuffered false DropTarget null Enabled true FocusPainted true Font javax.swing.plaf.FontUIResource[family=dialog.bold,name=Dialog,style=bold,size=12] Foreground javax.swing.plaf.ColorUIResource[r=0,g=0,b=0] HorizontalAlignment 0 HorizontalTextPosition 11 Icon null InputVerifier null Label "" Layout javax.swing.OverlayLayout@37c60d Locale null Location java.awt.Point[x=0,y=0] Margin javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14] MaximumSize java.awt.Dimension[width=35,height=11] MinimumSize java.awt.Dimension[width=35,height=11] Mnemonic 0 Model javax.swing.DefaultButtonModel@2b853b Name null NextFocusableComponent null Opaque true PreferredSize java.awt.Dimension[width=35,height=11] PressedIcon null RequestFocusEnabled true RolloverEnabled false RolloverIcon null RolloverSelectedIcon null Selected false SelectedIcon null Size java.awt.Dimension[width=0,height=0] Text "" ToolTipText null UI javax.swing.plaf.metal.MetalButtonUI@1616c7 VerticalAlignment 0 VerticalTextPosition 0 Visible true