arlut.csd.JDataComponent
Class JIPField

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.text.JTextComponent
                          |
                          +--javax.swing.JTextField
                                |
                                +--arlut.csd.JDataComponent.JentryField
                                      |
                                      +--arlut.csd.JDataComponent.JIPField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.SwingConstants

public class JIPField
extends JentryField

This class is an IPv4/IPv6 data display/entry widget for Ganymede. Its purpose is to allow the viewing and editing of either 4 or 16 byte Internet addresses and subnet masks.

Note that wherever Ganymede manipulates IP addresses, it does so in terms of unsigned bytes. Since Java does not provide an unsigned byte type, Ganymede uses the s2u() and u2s() static methods defined in this class to convert from the signed Java byte to the Ganymede 0-255 IP octet range.

See Also:
Serialized Form

Field Summary
private  boolean allowV6
           
static boolean debug
           
static int DEFAULT_COLS
           
private static java.lang.String IPv4allowedChars
           
private static java.lang.String IPv6allowedChars
           
private  boolean processingCallback
           
private  java.lang.String storedValue
           
 
Fields inherited from class arlut.csd.JDataComponent.JentryField
allowCallback, my_parent, notifier
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JIPField(boolean allowV6)
          Constructor which uses default fonts,no parent, default column size, and default foregound/background colors.
JIPField(boolean is_editable, boolean allowV6)
          Base constructor for JIPField
JIPField(boolean is_editable, arlut.csd.JDataComponent.JsetValueCallback callback, boolean allowV6)
          Constructor that allows for the creation of a JIPField that knows about its parent.
 
Method Summary
static java.lang.Byte[] genIPV4bytes(java.lang.String input)
          This method takes an IPv4 string in standard format and generates an array of 4 bytes that the Ganymede server can accept.
static java.lang.String genIPV4string(java.lang.Byte[] octets)
          This method generates a standard string representation of an IPv4 address from an array of 4 octets.
static java.lang.Byte[] genIPV6bytes(java.lang.String input)
          This method takes an IPv6 string in any of the standard RFC 1884 formats or a standard IPv4 string and generates an array of 16 bytes that the Ganymede server can accept as an IPv6 address.
static java.lang.String genIPV6string(java.lang.Byte[] octets)
          This method takes an array of 4 or 16 bytes and generates an optimal RFC 1884 string encoding suitable for display.
 char getCharAt(int n)
          returns the character located at position n in the JIPField value
 java.lang.Byte[] getValue()
          Returns the current IP value held in this JIPField.
private static boolean isAllowedV4(char ch)
          determines whether a given character is valid or invalid for a JIPField
private static boolean isAllowedV6(char ch)
          determines whether a given character is valid or invalid for a JIPField
static void main(java.lang.String[] argv)
           
private  void reportError(java.lang.String error)
          This private method is used to report an error condition to the user.
static short s2u(byte b)
          This method maps a u2s-encoded signed byte value to an int value between 0 and 255 inclusive.
 int sendCallback()
          When the JIPField looses focus, any changes made to the value in the JIPField need to be propogated to the server.
 void setValue(java.lang.Byte[] bytes)
          Sets the IP value held in this JIPField, without triggering a callback update.
static byte u2s(int x)
          This method maps an int value between 0 and 255 inclusive to a legal signed byte value.
 
Methods inherited from class arlut.csd.JDataComponent.JentryField
actionPerformed, focusGained, focusLost, getLength, getMaxStringSize, isAllowed, setCallback, setEnterHandler
 
Methods inherited from class javax.swing.JTextField
addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setDocument, setFont, setHorizontalAlignment, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static final boolean debug
See Also:
Constant Field Values

DEFAULT_COLS

public static int DEFAULT_COLS

IPv4allowedChars

private static java.lang.String IPv4allowedChars

IPv6allowedChars

private static java.lang.String IPv6allowedChars

storedValue

private java.lang.String storedValue

allowV6

private boolean allowV6

processingCallback

private boolean processingCallback
Constructor Detail

JIPField

public JIPField(boolean is_editable,
                boolean allowV6)
Base constructor for JIPField

Parameters:
is_editable - true if this JIPField is editable

JIPField

public JIPField(boolean allowV6)
Constructor which uses default fonts,no parent, default column size, and default foregound/background colors.


JIPField

public JIPField(boolean is_editable,
                arlut.csd.JDataComponent.JsetValueCallback callback,
                boolean allowV6)
Constructor that allows for the creation of a JIPField that knows about its parent.

Method Detail

getCharAt

public char getCharAt(int n)
returns the character located at position n in the JIPField value

Parameters:
n - position in the JIPField value from which to retrieve character

setValue

public void setValue(java.lang.Byte[] bytes)
Sets the IP value held in this JIPField, without triggering a callback update.

Parameters:
bytes - IP v4 or v6 address in byte array form

getValue

public java.lang.Byte[] getValue()
Returns the current IP value held in this JIPField.


sendCallback

public int sendCallback()
When the JIPField looses focus, any changes made to the value in the JIPField need to be propogated to the server. This method will handle that functionality. sendCallback is called when focus is lost, or when we are otherwise triggered.

Specified by:
sendCallback in class JentryField

reportError

private void reportError(java.lang.String error)
This private method is used to report an error condition to the user.


u2s

public static final byte u2s(int x)
This method maps an int value between 0 and 255 inclusive to a legal signed byte value.


s2u

public static final short s2u(byte b)
This method maps a u2s-encoded signed byte value to an int value between 0 and 255 inclusive.


isAllowedV4

private static final boolean isAllowedV4(char ch)
determines whether a given character is valid or invalid for a JIPField

Parameters:
ch - the character which is being tested for its validity

isAllowedV6

private static final boolean isAllowedV6(char ch)
determines whether a given character is valid or invalid for a JIPField

Parameters:
ch - the character which is being tested for its validity

genIPV4bytes

public static java.lang.Byte[] genIPV4bytes(java.lang.String input)
This method takes an IPv4 string in standard format and generates an array of 4 bytes that the Ganymede server can accept.


genIPV4string

public static java.lang.String genIPV4string(java.lang.Byte[] octets)
This method generates a standard string representation of an IPv4 address from an array of 4 octets.


genIPV6bytes

public static java.lang.Byte[] genIPV6bytes(java.lang.String input)
This method takes an IPv6 string in any of the standard RFC 1884 formats or a standard IPv4 string and generates an array of 16 bytes that the Ganymede server can accept as an IPv6 address.


genIPV6string

public static java.lang.String genIPV6string(java.lang.Byte[] octets)
This method takes an array of 4 or 16 bytes and generates an optimal RFC 1884 string encoding suitable for display.


main

public static void main(java.lang.String[] argv)