rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
setCursorOn();
public void sendKeys(String text) {// if (text == null) {// return;// } if (isStatusErrorCode() && !resetRequired) { resetError(); if (!cursorActive) setCursorOn(); } if (keyboardLocked) { if(text.equals("[reset]") || text.equals("[sysreq]") || text.equals("[attn]")) { simulateMnemonic(getMnemonicValue(text)); } else { if (isStatusErrorCode()) { Toolkit.getDefaultToolkit().beep(); return; } keysBuffered = true; setKBIndicatorOn(); if(bufferedKeys == null){ bufferedKeys = text; return; } else { bufferedKeys += text; return; } } } else { if (keysBuffered) { if (bufferedKeys != null) { text = bufferedKeys + text; } keysBuffered = false; setKBIndicatorOff(); bufferedKeys = null; } // check to see if position is in a field and if it is then change // current field to that field isInField(lastPos,true); if (text.length() == 1 && !text.equals("[") && !text.equals("]")) { simulateKeyStroke(text.charAt(0)); } else { strokenizer.setKeyStrokes(text); String s; boolean done = false; while (strokenizer.hasMoreKeyStrokes() && !keyboardLocked && !isStatusErrorCode() && !done) { s = strokenizer.nextKeyStroke(); if (s.length() == 1) { simulateKeyStroke(s.charAt(0)); } else { if (s != null) { simulateMnemonic(getMnemonicValue(s)); } else System.out.println(" send keys mnemonic " + s); } if (keyboardLocked) { bufferedKeys = strokenizer.getUnprocessedKeyStroked(); if (bufferedKeys != null) { keysBuffered = true; setKBIndicatorOn(); } done = true; } } } } }
if (!keysBuffered)
public void setCursorOn() { updateCursorLoc = true;// System.out.println("cursor on"); updateCursorLoc(); }
int editorWidth = comboBox.getBounds().width - arrowButtonWidth - 2;
int arrowSize = comboBox.getHeight(); int editorWidth = comboBox.getBounds().width - arrowSize;
public void layoutContainer(Container parent) { // Position editor component to the left of arrow button if combo box is // editable int editorWidth = comboBox.getBounds().width - arrowButtonWidth - 2; if (comboBox.isEditable()) editor.setBounds(borderInsets.left, borderInsets.top, editorWidth, comboBox.getBounds().height - borderInsets.left - borderInsets.top); arrowButton.setBounds(editorWidth, 2, arrowButtonWidth, comboBox.getBounds().height - 4); comboBox.revalidate(); }
editor.setBounds(borderInsets.left, borderInsets.top, editorWidth, comboBox.getBounds().height - borderInsets.left - borderInsets.top); arrowButton.setBounds(editorWidth, 2, arrowButtonWidth, comboBox.getBounds().height - 4);
editor.setBounds(0, 0, editorWidth, comboBox.getBounds().height); arrowButton.setBounds(editorWidth, 0, arrowSize, arrowSize);
public void layoutContainer(Container parent) { // Position editor component to the left of arrow button if combo box is // editable int editorWidth = comboBox.getBounds().width - arrowButtonWidth - 2; if (comboBox.isEditable()) editor.setBounds(borderInsets.left, borderInsets.top, editorWidth, comboBox.getBounds().height - borderInsets.left - borderInsets.top); arrowButton.setBounds(editorWidth, 2, arrowButtonWidth, comboBox.getBounds().height - 4); comboBox.revalidate(); }
Dimension d = new Dimension(0, 0); if (largestItemSize == null) largestItemSize = getLargestItemSize(); d.width += largestItemSize.getWidth(); d.height += largestItemSize.getHeight(); d.width += arrowButtonWidth; d.width += borderInsets.left + borderInsets.right; d.height += borderInsets.left + borderInsets.right; Insets insets = parent.getInsets(); d.width += insets.left + insets.right; d.width += insets.left + insets.right; return d;
return getPreferredSize((JComponent) parent);
public Dimension preferredLayoutSize(Container parent) { Dimension d = new Dimension(0, 0); if (largestItemSize == null) largestItemSize = getLargestItemSize(); // add size for the area that will display selected item d.width += largestItemSize.getWidth(); d.height += largestItemSize.getHeight(); // add size of the arrow button d.width += arrowButtonWidth; // add width and height of the border d.width += borderInsets.left + borderInsets.right; d.height += borderInsets.left + borderInsets.right; // Add combo box's insets Insets insets = parent.getInsets(); d.width += insets.left + insets.right; d.width += insets.left + insets.right; return d; }
int start = e.getIndex0(); int end = e.getIndex1();
public void intervalAdded(ListDataEvent e) { // must determine if the size of the combo box should change int start = e.getIndex0(); int end = e.getIndex1(); ComboBoxModel model = comboBox.getModel(); ListCellRenderer renderer = comboBox.getRenderer(); if (largestItemSize == null) largestItemSize = new Dimension(0, 0); for (int i = start; i < end; i++) { Object item = model.getElementAt(i); Component comp = renderer.getListCellRendererComponent(new JList(), item, -1, false, false); if (comp.getPreferredSize().getWidth() > largestItemSize.getWidth()) largestItemSize = comp.getPreferredSize(); } }
if (largestItemSize == null) largestItemSize = new Dimension(0, 0);
if (displaySize == null) displaySize = getDisplaySize(); if (displaySize.width < getDefaultSize().width) displaySize.width = getDefaultSize().width; if (displaySize.height < getDefaultSize().height) displaySize.height = getDefaultSize().height;
public void intervalAdded(ListDataEvent e) { // must determine if the size of the combo box should change int start = e.getIndex0(); int end = e.getIndex1(); ComboBoxModel model = comboBox.getModel(); ListCellRenderer renderer = comboBox.getRenderer(); if (largestItemSize == null) largestItemSize = new Dimension(0, 0); for (int i = start; i < end; i++) { Object item = model.getElementAt(i); Component comp = renderer.getListCellRendererComponent(new JList(), item, -1, false, false); if (comp.getPreferredSize().getWidth() > largestItemSize.getWidth()) largestItemSize = comp.getPreferredSize(); } }
for (int i = start; i < end; i++) { Object item = model.getElementAt(i); Component comp = renderer.getListCellRendererComponent(new JList(), item, -1, false, false); if (comp.getPreferredSize().getWidth() > largestItemSize.getWidth()) largestItemSize = comp.getPreferredSize(); }
comboBox.repaint();
public void intervalAdded(ListDataEvent e) { // must determine if the size of the combo box should change int start = e.getIndex0(); int end = e.getIndex1(); ComboBoxModel model = comboBox.getModel(); ListCellRenderer renderer = comboBox.getRenderer(); if (largestItemSize == null) largestItemSize = new Dimension(0, 0); for (int i = start; i < end; i++) { Object item = model.getElementAt(i); Component comp = renderer.getListCellRendererComponent(new JList(), item, -1, false, false); if (comp.getPreferredSize().getWidth() > largestItemSize.getWidth()) largestItemSize = comp.getPreferredSize(); } }
largestItemSize = getLargestItemSize();
displaySize = getDisplaySize();
public void intervalRemoved(ListDataEvent e) { // recalculate display size of the JComboBox. largestItemSize = getLargestItemSize(); comboBox.repaint(); }
{ if (e.getSource() instanceof JComboBox) { arrowButton.getModel().setPressed(true); arrowButton.getModel().setArmed(true); } comboBox.repaint(); if (e.getSource() instanceof BasicArrowButton) toggleOpenClose(); }
toggleOpenClose();
public void mousePressed(MouseEvent e) { if (comboBox.isEnabled()) { if (e.getSource() instanceof JComboBox) { arrowButton.getModel().setPressed(true); arrowButton.getModel().setArmed(true); } comboBox.repaint(); if (e.getSource() instanceof BasicArrowButton) toggleOpenClose(); } }
else if (e.getPropertyName().equals("font")) { Font font = (Font) e.getNewValue(); editor.setFont(font); listBox.setFont(font); arrowButton.setFont(font); comboBox.revalidate(); comboBox.repaint(); }
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("enabled")) { arrowButton.setEnabled(comboBox.isEnabled()); if (comboBox.isEditable()) comboBox.getEditor().getEditorComponent().setEnabled(comboBox .isEnabled()); } else if (e.getPropertyName().equals("editable")) { if (comboBox.isEditable()) { configureEditor(); addEditor(); } else { unconfigureEditor(); removeEditor(); } comboBox.revalidate(); comboBox.repaint(); } else if (e.getPropertyName().equals("dataModel")) { // remove ListDataListener from old model and add it to new model ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue(); if (oldModel != null) oldModel.removeListDataListener(listDataListener); if ((ComboBoxModel) e.getNewValue() != null) comboBox.getModel().addListDataListener(listDataListener); } // FIXME: Need to handle changes in other bound properties. }
arrowButton.addMouseListener(mouseListener);
arrowButton.setEnabled(comboBox.isEnabled()); arrowButton.setFont(comboBox.getFont()); arrowButton.setMargin(new Insets(0, 0, 0, 0));
public void configureArrowButton() { arrowButton.addMouseListener(mouseListener); }
editor.setFont(comboBox.getFont()); comboBox.getEditor().setItem(comboBox.getSelectedItem());
protected void configureEditor() { // FIXME: Need to implement. Set font and add listeners. }
return new Dimension(6, 17);
return new Dimension(100, 5);
protected Dimension getDefaultSize() { return new Dimension(6, 17); }
return null;
return MAXIMUM_SIZE;
public Dimension getMaximumSize(JComponent c) { return null; }
return null;
Dimension d = getDisplaySize(); Dimension arrowDim = arrowButton.getPreferredSize(); Dimension result = new Dimension(d.width + arrowDim.width, Math.max(d.height, arrowDim.height)); return result;
public Dimension getMinimumSize(JComponent c) { return null; }
return null;
return getMinimumSize(c);
public Dimension getPreferredSize(JComponent c) { // return null to indicate that combo box's layout will determin its // preferred size return null; }
configureArrowButton();
protected void installComponents() { // create and install arrow button arrowButton = createArrowButton(); comboBox.add(arrowButton); // Set list that will be used by BasicComboBoxRender // in order to determine the right colors when rendering listBox = new JList(); Color background = arrowButton.getBackground(); listBox.setBackground(background); listBox.setSelectionBackground(background.darker()); Color foreground = arrowButton.getForeground(); listBox.setForeground(foreground); listBox.setSelectionForeground(foreground); // set editor and renderer for the combo box. Editor is used // only if combo box becomes editable, otherwise renderer is used // to paint the selected item; combobox is not editable by default. comboBox.setRenderer(createRenderer()); comboBox.setEditor(createEditor()); editor = comboBox.getEditor().getEditorComponent(); // create drop down list of items popup = createPopup(); comboBox.revalidate(); }
Color background = arrowButton.getBackground(); listBox.setBackground(background); listBox.setSelectionBackground(background.darker()); Color foreground = arrowButton.getForeground(); listBox.setForeground(foreground); listBox.setSelectionForeground(foreground);
protected void installComponents() { // create and install arrow button arrowButton = createArrowButton(); comboBox.add(arrowButton); // Set list that will be used by BasicComboBoxRender // in order to determine the right colors when rendering listBox = new JList(); Color background = arrowButton.getBackground(); listBox.setBackground(background); listBox.setSelectionBackground(background.darker()); Color foreground = arrowButton.getForeground(); listBox.setForeground(foreground); listBox.setSelectionForeground(foreground); // set editor and renderer for the combo box. Editor is used // only if combo box becomes editable, otherwise renderer is used // to paint the selected item; combobox is not editable by default. comboBox.setRenderer(createRenderer()); comboBox.setEditor(createEditor()); editor = comboBox.getEditor().getEditorComponent(); // create drop down list of items popup = createPopup(); comboBox.revalidate(); }
comboBox.setBackground(defaults.getColor("ComboBox.background")); comboBox.setFont(defaults.getFont("ComboBox.font")); comboBox.setForeground(defaults.getColor("ComboBox.foreground"));
if (comboBox.getFont() instanceof UIResource) comboBox.setFont(defaults.getFont("ComboBox.font")); if (comboBox.getForeground() instanceof UIResource) comboBox.setForeground(defaults.getColor("ComboBox.foreground"));
protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); comboBox.setBackground(defaults.getColor("ComboBox.background")); comboBox.setFont(defaults.getFont("ComboBox.font")); comboBox.setForeground(defaults.getColor("ComboBox.foreground")); // Set default color that should be used to to render selected item // of the combo box. shadow = defaults.getColor("Button.shadow"); darkShadow = defaults.getColor("Button.darkShadow"); lightHighlight = defaults.getColor("Button.light"); highlight = defaults.getColor("Button.highlight"); }
shadow = defaults.getColor("Button.shadow"); darkShadow = defaults.getColor("Button.darkShadow"); lightHighlight = defaults.getColor("Button.light"); highlight = defaults.getColor("Button.highlight");
if (comboBox.getBackground() instanceof UIResource) comboBox.setBackground(defaults.getColor("ComboBox.background")); shadow = defaults.getColor("ComboBox.buttonShadow"); darkShadow = defaults.getColor("ComboBox.buttonDarkShadow"); highlight = defaults.getColor("ComboBox.buttonHighlight");
protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); comboBox.setBackground(defaults.getColor("ComboBox.background")); comboBox.setFont(defaults.getFont("ComboBox.font")); comboBox.setForeground(defaults.getColor("ComboBox.foreground")); // Set default color that should be used to to render selected item // of the combo box. shadow = defaults.getColor("Button.shadow"); darkShadow = defaults.getColor("Button.darkShadow"); lightHighlight = defaults.getColor("Button.light"); highlight = defaults.getColor("Button.highlight"); }
comboBox.addMouseListener(mouseListener);
arrowButton.addMouseListener(mouseListener);
protected void installListeners() { // install combo box's listeners propertyChangeListener = createPropertyChangeListener(); comboBox.addPropertyChangeListener(propertyChangeListener); focusListener = createFocusListener(); comboBox.addFocusListener(focusListener); itemListener = createItemListener(); comboBox.addItemListener(itemListener); keyListener = createKeyListener(); comboBox.addKeyListener(keyListener); mouseListener = createMouseListener(); comboBox.addMouseListener(mouseListener); // install listeners that listen to combo box model listDataListener = createListDataListener(); comboBox.getModel().addListDataListener(listDataListener); configureArrowButton(); }
configureArrowButton();
protected void installListeners() { // install combo box's listeners propertyChangeListener = createPropertyChangeListener(); comboBox.addPropertyChangeListener(propertyChangeListener); focusListener = createFocusListener(); comboBox.addFocusListener(focusListener); itemListener = createItemListener(); comboBox.addItemListener(itemListener); keyListener = createKeyListener(); comboBox.addKeyListener(keyListener); mouseListener = createMouseListener(); comboBox.addMouseListener(mouseListener); // install listeners that listen to combo box model listDataListener = createListDataListener(); comboBox.getModel().addListDataListener(listDataListener); configureArrowButton(); }
if (comboBox.isEditable())
if (!comboBox.isEditable())
public boolean isFocusTraversable(JComboBox c) { if (comboBox.isEditable()) return true; return false; }
if (c instanceof JComboBox) { JComboBox cb = (JComboBox) c; paintBorder(g, comboBox.getBounds(), hasFocus); Rectangle rect = rectangleForCurrentValue(); paintCurrentValueBackground(g, rect, hasFocus); paintCurrentValue(g, rect, hasFocus); }
Rectangle rect = rectangleForCurrentValue(); paintCurrentValueBackground(g, rect, hasFocus); paintCurrentValue(g, rect, hasFocus);
public void paint(Graphics g, JComponent c) { if (c instanceof JComboBox) { JComboBox cb = (JComboBox) c; paintBorder(g, comboBox.getBounds(), hasFocus); Rectangle rect = rectangleForCurrentValue(); paintCurrentValueBackground(g, rect, hasFocus); paintCurrentValue(g, rect, hasFocus); } }
Component comp = comboBox.getRenderer() .getListCellRendererComponent(listBox, (currentValue != null ? currentValue : ""), -1, isPressed, hasFocus); if (! comboBox.isEnabled()) comp.setEnabled(false); g.translate(borderInsets.left, borderInsets.top); comp.setBounds(0, 0, bounds.width, bounds.height); comp.paint(g); g.translate(-borderInsets.left, -borderInsets.top); comboBox.revalidate();
Component comp = comboBox.getRenderer().getListCellRendererComponent( listBox, (currentValue != null ? currentValue : ""), -1, isPressed, hasFocus); if (! comboBox.isEnabled()) { comp.setBackground(UIManager.getLookAndFeelDefaults().getColor( "ComboBox.disabledBackground")); comp.setForeground(UIManager.getLookAndFeelDefaults().getColor( "ComboBox.disabledForeground")); comp.setEnabled(false); } comp.setBounds(0, 0, bounds.width, bounds.height); comp.setFont(comboBox.getFont()); comp.paint(g); comboBox.revalidate();
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { if (! comboBox.isEditable()) { Object currentValue = comboBox.getSelectedItem(); boolean isPressed = arrowButton.getModel().isPressed(); /* Gets the component to be drawn for the current value. * If there is currently no selected item we will take an empty * String as replacement. */ Component comp = comboBox.getRenderer() .getListCellRendererComponent(listBox, (currentValue != null ? currentValue : ""), -1, isPressed, hasFocus); if (! comboBox.isEnabled()) comp.setEnabled(false); g.translate(borderInsets.left, borderInsets.top); comp.setBounds(0, 0, bounds.width, bounds.height); comp.paint(g); g.translate(-borderInsets.left, -borderInsets.top); comboBox.revalidate(); } else comboBox.getEditor().setItem(comboBox.getSelectedItem()); }
Rectangle cbBounds = comboBox.getBounds(); Rectangle rectForCurrentValue = new Rectangle(cbBounds.x + borderInsets.left, cbBounds.y + borderInsets.top, cbBounds.width - arrowButtonWidth - borderInsets.left - borderInsets.right, cbBounds.height - borderInsets.top - borderInsets.bottom);
Rectangle cbBounds = SwingUtilities.getLocalBounds(comboBox); Rectangle abBounds = arrowButton.getBounds(); Rectangle rectForCurrentValue = new Rectangle(cbBounds.x, cbBounds.y, cbBounds.width - abBounds.width, cbBounds.height);
protected Rectangle rectangleForCurrentValue() { Rectangle cbBounds = comboBox.getBounds(); // Subtract width or the arrow button and border insets Rectangle rectForCurrentValue = new Rectangle(cbBounds.x + borderInsets.left, cbBounds.y + borderInsets.top, cbBounds.width - arrowButtonWidth - borderInsets.left - borderInsets.right, cbBounds.height - borderInsets.top - borderInsets.bottom); return rectForCurrentValue; }
arrowButton.removeMouseListener(mouseListener);
public void unconfigureArrowButton() { arrowButton.removeMouseListener(mouseListener); }
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
if (comboBox.getFont() instanceof UIResource) comboBox.setFont(null);
protected void uninstallDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); comboBox.setBackground(null); comboBox.setFont(null); comboBox.setForeground(null); shadow = null; darkShadow = null; lightHighlight = null; highlight = null; }
comboBox.setBackground(null); comboBox.setFont(null); comboBox.setForeground(null);
if (comboBox.getForeground() instanceof UIResource) comboBox.setForeground(null); if (comboBox.getBackground() instanceof UIResource) comboBox.setBackground(null);
protected void uninstallDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); comboBox.setBackground(null); comboBox.setFont(null); comboBox.setForeground(null); shadow = null; darkShadow = null; lightHighlight = null; highlight = null; }
lightHighlight = null;
protected void uninstallDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); comboBox.setBackground(null); comboBox.setFont(null); comboBox.setForeground(null); shadow = null; darkShadow = null; lightHighlight = null; highlight = null; }
comboBox.removeMouseListener(mouseListener);
arrowButton.removeMouseListener(mouseListener);
protected void uninstallListeners() { comboBox.removePropertyChangeListener(propertyChangeListener); propertyChangeListener = null; comboBox.removeFocusListener(focusListener); focusListener = null; comboBox.removeItemListener(itemListener); itemListener = null; comboBox.removeKeyListener(keyListener); keyListener = null; comboBox.removeMouseListener(mouseListener); mouseListener = null; comboBox.getModel().removeListDataListener(listDataListener); listDataListener = null; unconfigureArrowButton(); }
unconfigureArrowButton();
protected void uninstallListeners() { comboBox.removePropertyChangeListener(propertyChangeListener); propertyChangeListener = null; comboBox.removeFocusListener(focusListener); focusListener = null; comboBox.removeItemListener(itemListener); itemListener = null; comboBox.removeKeyListener(keyListener); keyListener = null; comboBox.removeMouseListener(mouseListener); mouseListener = null; comboBox.getModel().removeListDataListener(listDataListener); listDataListener = null; unconfigureArrowButton(); }
InputMap im = new InputMap ();
InputMapUIResource im = new InputMapUIResource ();
public Object createValue(UIDefaults table) { InputMap im = new InputMap (); for (int i = 0; 2*i+1 < bind.length; ++i) { im.put (KeyStroke.getKeyStroke ((String) bind[2*i]), bind[2*i+1]); } return im; }
im.put (KeyStroke.getKeyStroke ((String) bind[2*i]),
Object curr = bind[2*i]; if (curr instanceof KeyStroke) im.put((KeyStroke) curr, bind[2*i+1]); else im.put(KeyStroke.getKeyStroke((String) curr),
public Object createValue(UIDefaults table) { InputMap im = new InputMap (); for (int i = 0; 2*i+1 < bind.length; ++i) { im.put (KeyStroke.getKeyStroke ((String) bind[2*i]), bind[2*i+1]); } return im; }
super();
public FocusManager() { // TODO }
return null;
KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); if (fm instanceof FocusManager) return (FocusManager) fm; else { System.err.println("The Swing FocusManager API has been obsoleted by"); System.err.println("the new KeyboardFocusManager system."); System.err.println("You should either not use the Swing FocusManager"); System.err.println("API or set the system property"); System.err.println ("gnu.java.awt.FocusManager=javax.swing.FocusManager"); } return null;
public static FocusManager getCurrentManager() { return null; // TODO }
KeyboardFocusManager.setCurrentKeyboardFocusManager(manager);
public static void setCurrentManager(FocusManager manager) { // TODO }
setFocusable(false);
public BasicArrowButton(int direction) { super(); setDirection(direction); }
return MAXIMUM_SIZE;
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
public Dimension getMaximumSize() { return MAXIMUM_SIZE; }
return MINIMUM_SIZE;
return new Dimension(5, 5);
public Dimension getMinimumSize() { return MINIMUM_SIZE; }
return PREFERRED_SIZE;
return new Dimension(16, 16);
public Dimension getPreferredSize() { return PREFERRED_SIZE; }
Rectangle bounds = getBounds(); int size = bounds.height / 4; int x = bounds.x + (bounds.width - size) / 2; int y = (bounds.height - size) / 4;
int height = getHeight(); int size = height / 4; int x = (getWidth() - size) / 2; int y = (height - size) / 2;
public void paint(Graphics g) { super.paint(g); Rectangle bounds = getBounds(); int size = bounds.height / 4; int x = bounds.x + (bounds.width - size) / 2; int y = (bounds.height - size) / 4; ButtonModel m = getModel(); if (m.isArmed()) { x++; y++; } paintTriangle(g, x, y, size, direction, isEnabled()); }
synchronized(obj.openGroupNodeHash) {
synchronized(this.openGroupNodeHash) {
private String dealWithClosingGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(obj.openGroupNodeHash) { Iterator iter = obj.openGroupNodeHash.iterator(); // Must be in synchronized block while (iter.hasNext()) { Group openGroup = (Group) iter.next(); // determine if this group that we belong to is already // open or not. if(!obj.groupMemberHash.contains(openGroup)) { // its *not* a member of this group and its still open, // so we need to close it. if (sPrettyXDFOutput) writeOut(outputstream, indent); writeOut(outputstream, "</" + openGroup.classXDFNodeName + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); obj.openGroupNodeHash.remove(openGroup); // peel off some indent indent = indent.substring(0,indent.length() - sPrettyXDFOutputIndentation.length()); } } } } return indent; }
Iterator iter = obj.openGroupNodeHash.iterator();
Iterator iter = this.openGroupNodeHash.iterator();
private String dealWithClosingGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(obj.openGroupNodeHash) { Iterator iter = obj.openGroupNodeHash.iterator(); // Must be in synchronized block while (iter.hasNext()) { Group openGroup = (Group) iter.next(); // determine if this group that we belong to is already // open or not. if(!obj.groupMemberHash.contains(openGroup)) { // its *not* a member of this group and its still open, // so we need to close it. if (sPrettyXDFOutput) writeOut(outputstream, indent); writeOut(outputstream, "</" + openGroup.classXDFNodeName + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); obj.openGroupNodeHash.remove(openGroup); // peel off some indent indent = indent.substring(0,indent.length() - sPrettyXDFOutputIndentation.length()); } } } } return indent; }
obj.openGroupNodeHash.remove(openGroup);
this.openGroupNodeHash.remove(openGroup);
private String dealWithClosingGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(obj.openGroupNodeHash) { Iterator iter = obj.openGroupNodeHash.iterator(); // Must be in synchronized block while (iter.hasNext()) { Group openGroup = (Group) iter.next(); // determine if this group that we belong to is already // open or not. if(!obj.groupMemberHash.contains(openGroup)) { // its *not* a member of this group and its still open, // so we need to close it. if (sPrettyXDFOutput) writeOut(outputstream, indent); writeOut(outputstream, "</" + openGroup.classXDFNodeName + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); obj.openGroupNodeHash.remove(openGroup); // peel off some indent indent = indent.substring(0,indent.length() - sPrettyXDFOutputIndentation.length()); } } } } return indent; }
synchronized(obj.openGroupNodeHash) {
synchronized(this.openGroupNodeHash) {
private String dealWithOpeningGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(obj.openGroupNodeHash) { Iterator iter = obj.groupMemberHash.iterator(); // Must be in synchronized block while (iter.hasNext()) { Group memberGroup = (Group) iter.next(); // determine if this group that we belong to is already // open or not. if(!obj.openGroupNodeHash.contains(memberGroup)) { // its *not* already open, so we bump up the indentation, // open it and add it to the open group node list. indent.concat(sPrettyXDFOutputIndentation); memberGroup.toXDFOutputStream(outputstream, indent); obj.openGroupNodeHash.add(memberGroup); } } } } return indent; }
if(!obj.openGroupNodeHash.contains(memberGroup)) {
if(!this.openGroupNodeHash.contains(memberGroup)) {
private String dealWithOpeningGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(obj.openGroupNodeHash) { Iterator iter = obj.groupMemberHash.iterator(); // Must be in synchronized block while (iter.hasNext()) { Group memberGroup = (Group) iter.next(); // determine if this group that we belong to is already // open or not. if(!obj.openGroupNodeHash.contains(memberGroup)) { // its *not* already open, so we bump up the indentation, // open it and add it to the open group node list. indent.concat(sPrettyXDFOutputIndentation); memberGroup.toXDFOutputStream(outputstream, indent); obj.openGroupNodeHash.add(memberGroup); } } } } return indent; }
indent.concat(sPrettyXDFOutputIndentation); memberGroup.toXDFOutputStream(outputstream, indent); obj.openGroupNodeHash.add(memberGroup);
newIndent.append(sPrettyXDFOutputIndentation); memberGroup.toXDFOutputStream(outputstream, new Hashtable(), newIndent.toString(), true, null, null); this.openGroupNodeHash.add(memberGroup);
private String dealWithOpeningGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(obj.openGroupNodeHash) { Iterator iter = obj.groupMemberHash.iterator(); // Must be in synchronized block while (iter.hasNext()) { Group memberGroup = (Group) iter.next(); // determine if this group that we belong to is already // open or not. if(!obj.openGroupNodeHash.contains(memberGroup)) { // its *not* already open, so we bump up the indentation, // open it and add it to the open group node list. indent.concat(sPrettyXDFOutputIndentation); memberGroup.toXDFOutputStream(outputstream, indent); obj.openGroupNodeHash.add(memberGroup); } } } } return indent; }
return indent;
return newIndent.toString();
private String dealWithOpeningGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(obj.openGroupNodeHash) { Iterator iter = obj.groupMemberHash.iterator(); // Must be in synchronized block while (iter.hasNext()) { Group memberGroup = (Group) iter.next(); // determine if this group that we belong to is already // open or not. if(!obj.openGroupNodeHash.contains(memberGroup)) { // its *not* already open, so we bump up the indentation, // open it and add it to the open group node list. indent.concat(sPrettyXDFOutputIndentation); memberGroup.toXDFOutputStream(outputstream, indent); obj.openGroupNodeHash.add(memberGroup); } } } } return indent; }
{ writeOut(outputstream,"<" + sXDFRootNodeName); } else { writeOut(outputstream,"<" + nodeNameString); }
nodeNameString = sXDFRootNodeName; writeOut(outputstream,"<" + nodeNameString);
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; }
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE);
if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE);
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent);
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ;
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
writeOut(outputstream, "</"+nodeNameString + ">");
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
return ;
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else {
indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode)
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
}
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
writeOut(outputstream, ">");
public void toXDFOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); } // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); // indent node if desired // For printing the opening statement we need to invoke a little // Voodoo to keep the DTD happy: the first structure node is always // called by the root node name instead of the usual nodeNameString // We can tell this by checking if this object is derived from class // Structure and if XMLDeclAttrib defined/populated with information // NOTE: This isnt really the way to do this. We need to check if 'this' is // is or has as a superclass xdf.Structure instead of the 'string check' below. // check is class Strucuture & XMLDeclAttribs populated? if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream,"<" + sXDFRootNodeName); // print opening root node statement } else { writeOut(outputstream,"<" + nodeNameString); // print opening statement } } // gather info about XMLAttributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { for (int i = 0; i < attribs.size(); i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); //it is the simplest node, with opening/closing node, no child, no PCDATA if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName == null){ writeOut(outputstream, "></" + nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null) && (childObjs.size() !=0)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list for (int i = 0; i < childObjs.size(); i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); // Im not sure this synchronized wrapper is needed, we are // only accessing stuff here.. Also, should synchronzied wrapper // occur back in the getXMLInfo method instead where the orig // access occured?!? synchronized(objectList) { Iterator iter = objectList.iterator(); // Must be in synchronized block while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { String newindent = indent + sPrettyXDFOutputIndentation; dealWithOpeningGroupNodes(containedObj, outputstream, indent); dealWithClosingGroupNodes(containedObj, outputstream, indent); containedObj.toXDFOutputStream(outputstream, new Hashtable(), newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { writeOut(outputstream, pcdata); //write out closing node after PCDATA, leaving no space between them. //k.z. 10/18/2000 if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; //now we are done, return! //k.z. 10/18/2000 }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); writeOut(outputstream, "</"+nodeNameString + ">"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); return ; } // ok, now deal with closing the node if (nodeNameString != null) { // Needed?? //dealWithClosingGroupNodes(containedObj, outputstream, indent); //Brian: we have to fix this, no whitespace should be allowed between //PCDATA and closing node if (sPrettyXDFOutput) writeOut(outputstream, indent); if (!dontCloseNode) if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) { writeOut(outputstream, "</"+sXDFRootNodeName+">"); } else { writeOut(outputstream, "</"+nodeNameString+">"); } } } else { if(dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); }
String t = new Date(e.getWhen()).toString();
public void actionPerformed(ActionEvent e) { String t = new Date(e.getWhen()).toString(); Session ses; for (int x = 0; x < sessions.size(); x++) { try { ses = (Session)sessions.get(x); if (ses.isConnected() && ses.isSendKeepAlive()) { ses.getVT().sendHeartBeat(); //System.out.println(" sent heartbeat to " + ses.getSessionName()); } } catch (Exception ex) { System.out.println(ex.getMessage()); } } //System.out.println(" sending heartbeats " + t); }
if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalScrollBarUI instance; if (o == null) { instance = new MetalScrollBarUI(); instances.put(component, instance); } else instance = (MetalScrollBarUI) o; return instance;
return new MetalScrollBarUI();
public static ComponentUI createUI(JComponent component) { if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalScrollBarUI instance; if (o == null) { instance = new MetalScrollBarUI(); instances.put(component, instance); } else instance = (MetalScrollBarUI) o; return instance; }
g.setColor(thumbDarkShadowColor); g.drawRect(thumbBounds.x, thumbBounds.y, thumbBounds.width - 1, thumbBounds.height - 1);
int hAdj = 1; int wAdj = 1; if (scrollbar.getOrientation() == HORIZONTAL) hAdj++; else wAdj++; g.setColor(new Color(102, 102, 153)); g.drawRect(thumbBounds.x, thumbBounds.y, thumbBounds.width - wAdj, thumbBounds.height - hAdj);
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { // first we fill the background g.setColor(thumbColor); g.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height); // draw the outer dark line g.setColor(thumbDarkShadowColor); g.drawRect(thumbBounds.x, thumbBounds.y, thumbBounds.width - 1, thumbBounds.height - 1); // draw the inner light line g.setColor(thumbHighlightColor); g.drawLine(thumbBounds.x + 1, thumbBounds.y + 1, thumbBounds.x + thumbBounds.width - 2, thumbBounds.y + 1); g.drawLine(thumbBounds.x + 1, thumbBounds.y + 1, thumbBounds.x + 1, thumbBounds.y + thumbBounds.height - 2); // draw the shadow line UIDefaults def = UIManager.getLookAndFeelDefaults(); g.setColor(def.getColor("ScrollBar.shadow")); g.drawLine(thumbBounds.x + 1, thumbBounds.y + thumbBounds.height, thumbBounds.x + thumbBounds.width, thumbBounds.y + thumbBounds.height); // draw the pattern MetalUtils.fillMetalPattern(g, thumbBounds.x + 3, thumbBounds.y + 3, thumbBounds.width - 6, thumbBounds.height - 6, thumbHighlightColor, thumbDarkShadowColor); }
thumbHighlightColor, thumbDarkShadowColor);
thumbHighlightColor, new Color(102, 102, 153));
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { // first we fill the background g.setColor(thumbColor); g.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height); // draw the outer dark line g.setColor(thumbDarkShadowColor); g.drawRect(thumbBounds.x, thumbBounds.y, thumbBounds.width - 1, thumbBounds.height - 1); // draw the inner light line g.setColor(thumbHighlightColor); g.drawLine(thumbBounds.x + 1, thumbBounds.y + 1, thumbBounds.x + thumbBounds.width - 2, thumbBounds.y + 1); g.drawLine(thumbBounds.x + 1, thumbBounds.y + 1, thumbBounds.x + 1, thumbBounds.y + thumbBounds.height - 2); // draw the shadow line UIDefaults def = UIManager.getLookAndFeelDefaults(); g.setColor(def.getColor("ScrollBar.shadow")); g.drawLine(thumbBounds.x + 1, thumbBounds.y + thumbBounds.height, thumbBounds.x + thumbBounds.width, thumbBounds.y + thumbBounds.height); // draw the pattern MetalUtils.fillMetalPattern(g, thumbBounds.x + 3, thumbBounds.y + 3, thumbBounds.width - 6, thumbBounds.height - 6, thumbHighlightColor, thumbDarkShadowColor); }
return ftpFile.getTimestamp().getTimeInMillis();
return ftpFile.lastModified().getTime();
public long getLastModified() throws IOException { //return ftpFile.lastModified().getTime(); return ftpFile.getTimestamp().getTimeInMillis(); }
return ftpFile.isDirectory();
return ftpFile.isDir();
public boolean isDirectory() { return ftpFile.isDirectory(); }
return !ftpFile.isFile();
return !ftpFile.isDir() && !ftpFile.isLink();
public boolean isFile() { return !ftpFile.isFile(); }
styleTable.put(DEFAULT_STYLE, defaultStyle);
public StyleContext() { listenerList = new EventListenerList(); styleTable = new Hashtable(); }
(sb.charAt(len) <= ' ' || sb.charAt(len) >= '\uff20' )) {
(sb.charAt(len) < ' ' || sb.charAt(len) >= '\uff20' )) {
protected void readFormatTable(ByteArrayOutputStream baosp,int readType, CodePage codePage) { ScreenField sf; boolean isSigned = false; char c; if (masterMDT) { StringBuffer sb = new StringBuffer(); for (int x = 0; x < sizeFields; x++) { isSigned = false; sf = screenFields[x]; if (sf.mdt || (readType == CMD_READ_INPUT_FIELDS)) { sb.setLength(0); sb.append(sf.getText()); if (readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT) { int len = sb.length() - 1; // we strip out all '\u0020' and less while (len >= 0 && (sb.charAt(len) <= ' ' || sb.charAt(len) >= '\uff20' )) { sb.deleteCharAt(len--); } }// System.out.println("field " + sf.toString());// System.out.println(">" + sb.toString() + "<");// System.out.println(" field is all nulls"); if (sf.isSignedNumeric() && sb.charAt(sb.length() - 1) == '-') { isSigned = true; sb.setLength(sb.length() - 1); } int len3 = sb.length(); if (len3 > 0 || (readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT)) { if ((readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT)) { baosp.write(17); // start of field data baosp.write(sf.startRow()+1); baosp.write(sf.startCol()+1); }// int len = sb.length(); for (int k = 0; k < len3; k++) { c = sb.charAt(k); // here we have to check for special instances of the // characters in the string field. Attribute bytes // are encoded with an offset of \uff00 // This is a hack !!!!!!!!!!! // See ScreenField object for a description if (c < ' ' || c >= '\uff20') { // if it is an offset attribute byte we just pass // it straight on to the output stream if (c >= '\uff20' && c <= '\uff3f') { baosp.write(c - '\uff00'); } else baosp.write(codePage.getEBCDIC(' ')); } else { if (isSigned && k == len3 - 1) { baosp.write(0xd0 | (0x0f & c)); } else baosp.write(codePage.uni2ebcdic(c)); } } } } } } }
if (sf.isSignedNumeric() && sb.charAt(sb.length() - 1) == '-') {
if (sf.isSignedNumeric() && sb.length() > 0 && sb.charAt(sb.length() - 1) == '-') {
protected void readFormatTable(ByteArrayOutputStream baosp,int readType, CodePage codePage) { ScreenField sf; boolean isSigned = false; char c; if (masterMDT) { StringBuffer sb = new StringBuffer(); for (int x = 0; x < sizeFields; x++) { isSigned = false; sf = screenFields[x]; if (sf.mdt || (readType == CMD_READ_INPUT_FIELDS)) { sb.setLength(0); sb.append(sf.getText()); if (readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT) { int len = sb.length() - 1; // we strip out all '\u0020' and less while (len >= 0 && (sb.charAt(len) <= ' ' || sb.charAt(len) >= '\uff20' )) { sb.deleteCharAt(len--); } }// System.out.println("field " + sf.toString());// System.out.println(">" + sb.toString() + "<");// System.out.println(" field is all nulls"); if (sf.isSignedNumeric() && sb.charAt(sb.length() - 1) == '-') { isSigned = true; sb.setLength(sb.length() - 1); } int len3 = sb.length(); if (len3 > 0 || (readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT)) { if ((readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT)) { baosp.write(17); // start of field data baosp.write(sf.startRow()+1); baosp.write(sf.startCol()+1); }// int len = sb.length(); for (int k = 0; k < len3; k++) { c = sb.charAt(k); // here we have to check for special instances of the // characters in the string field. Attribute bytes // are encoded with an offset of \uff00 // This is a hack !!!!!!!!!!! // See ScreenField object for a description if (c < ' ' || c >= '\uff20') { // if it is an offset attribute byte we just pass // it straight on to the output stream if (c >= '\uff20' && c <= '\uff3f') { baosp.write(c - '\uff00'); } else baosp.write(codePage.getEBCDIC(' ')); } else { if (isSigned && k == len3 - 1) { baosp.write(0xd0 | (0x0f & c)); } else baosp.write(codePage.uni2ebcdic(c)); } } } } } } }
jarClassPaths = userDir + File.separator + "jython.jar";
jarClassPaths = "." + File.pathSeparator + "jython.jar" + File.pathSeparator + "jt400.jar" + File.pathSeparator + "itext.jar"; if (sessions.contains("scriptClassPath")) { jarClassPaths += File.pathSeparator + sessions.getProperty("scriptClassPath"); }
private void initJarPaths() { String userDir = System.getProperty("user.dir"); if (new File(userDir + File.separator + "jython.jar").exists()) { jarClassPaths = userDir + File.separator + "jython.jar"; } if (jarClassPaths != null) System.setProperty("python.path",jarClassPaths); splash.updateProgress(++step); }
Locale.setDefault(parseLocal(getParm("-L",args))); LangTool.init(); if (args[0].startsWith("-")) { m.sessionArgs = null; } else { m.splash.updateProgress(++m.step); m.frame1.setVisible(true); m.splash.setVisible(false); m.frame1.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); LangTool.init(); m.sessionArgs = args; } } else { LangTool.init();
static public void main(String[] args) { if (isSpecified("-MDI",args)) { useMDIFrames = true; } if (!isSpecified("-nc",args)) { if (!checkBootStrapper(args)) { // if we did not find a running instance and the -d options is // specified start up the bootstrap deamon to allow checking // for running instances if (isSpecified("-d",args)) { strapper = new BootStrapper(); strapper.start(); } } else { System.exit(0); } } My5250 m = new My5250(); if (strapper != null) strapper.addBootListener(m); if (args.length > 0) { if (isSpecified("-width",args) || isSpecified("-height",args)) { int width = m.frame1.getWidth(); int height = m.frame1.getHeight(); if (isSpecified("-width",args)) { width = Integer.parseInt(m.getParm("-width",args)); } if (isSpecified("-height",args)) { height = Integer.parseInt(m.getParm("-height",args)); } m.frame1.setSize(width,height); m.frame1.centerFrame(); } /** * @todo this crap needs to be rewritten it is a mess */ if (args[0].startsWith("-")) { // check if a session parameter is specified on the command line if (isSpecified("-s",args)) { String sd = getParm("-s",args); if (sessions.containsKey(sd)) { sessions.setProperty("emul.default",sd); } else { args = null; } } // check if a locale parameter is specified on the command line if (isSpecified("-L",args)) { Locale.setDefault(parseLocal(getParm("-L",args))); LangTool.init(); if (args[0].startsWith("-")) { m.sessionArgs = null; } else { m.splash.updateProgress(++m.step); m.frame1.setVisible(true); m.splash.setVisible(false); m.frame1.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); LangTool.init(); m.sessionArgs = args; } } else { LangTool.init(); if (isSpecified("-s",args)) m.sessionArgs = args; else m.sessionArgs = null; } } else { LangTool.init(); m.sessionArgs = args; } } else { LangTool.init(); m.sessionArgs = null; } if (m.sessionArgs != null) { // BEGIN // 2001/09/19 natural computing MR Vector os400_sessions = new Vector(); Vector session_params = new Vector(); for (int x = 0; x < args.length; x++) { if (args[x].equals("-s")) { x++; if (args[x] != null && sessions.containsKey(args[x])) { os400_sessions.addElement(args[x]); }else{ x--; session_params.addElement(args[x]); } }else{ session_params.addElement(args[x]); } } for (int x = 0; x < session_params.size(); x++) m.sessionArgs[x] = session_params.elementAt(x).toString(); m.startNewSession(); for (int x = 1; x < os400_sessions.size(); x++ ) { String sel = os400_sessions.elementAt(x).toString(); if (!m.frame1.isVisible()) { m.splash.updateProgress(++m.step); m.frame1.setVisible(true); m.splash.setVisible(false); m.frame1.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } m.sessionArgs = new String[NUM_PARMS]; m.parseArgs(sessions.getProperty(sel),m.sessionArgs); m.newSession(sel,m.sessionArgs); } // 2001/09/19 natural computing MR // END } else { m.startNewSession(); } }
}
static public void main(String[] args) { if (isSpecified("-MDI",args)) { useMDIFrames = true; } if (!isSpecified("-nc",args)) { if (!checkBootStrapper(args)) { // if we did not find a running instance and the -d options is // specified start up the bootstrap deamon to allow checking // for running instances if (isSpecified("-d",args)) { strapper = new BootStrapper(); strapper.start(); } } else { System.exit(0); } } My5250 m = new My5250(); if (strapper != null) strapper.addBootListener(m); if (args.length > 0) { if (isSpecified("-width",args) || isSpecified("-height",args)) { int width = m.frame1.getWidth(); int height = m.frame1.getHeight(); if (isSpecified("-width",args)) { width = Integer.parseInt(m.getParm("-width",args)); } if (isSpecified("-height",args)) { height = Integer.parseInt(m.getParm("-height",args)); } m.frame1.setSize(width,height); m.frame1.centerFrame(); } /** * @todo this crap needs to be rewritten it is a mess */ if (args[0].startsWith("-")) { // check if a session parameter is specified on the command line if (isSpecified("-s",args)) { String sd = getParm("-s",args); if (sessions.containsKey(sd)) { sessions.setProperty("emul.default",sd); } else { args = null; } } // check if a locale parameter is specified on the command line if (isSpecified("-L",args)) { Locale.setDefault(parseLocal(getParm("-L",args))); LangTool.init(); if (args[0].startsWith("-")) { m.sessionArgs = null; } else { m.splash.updateProgress(++m.step); m.frame1.setVisible(true); m.splash.setVisible(false); m.frame1.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); LangTool.init(); m.sessionArgs = args; } } else { LangTool.init(); if (isSpecified("-s",args)) m.sessionArgs = args; else m.sessionArgs = null; } } else { LangTool.init(); m.sessionArgs = args; } } else { LangTool.init(); m.sessionArgs = null; } if (m.sessionArgs != null) { // BEGIN // 2001/09/19 natural computing MR Vector os400_sessions = new Vector(); Vector session_params = new Vector(); for (int x = 0; x < args.length; x++) { if (args[x].equals("-s")) { x++; if (args[x] != null && sessions.containsKey(args[x])) { os400_sessions.addElement(args[x]); }else{ x--; session_params.addElement(args[x]); } }else{ session_params.addElement(args[x]); } } for (int x = 0; x < session_params.size(); x++) m.sessionArgs[x] = session_params.elementAt(x).toString(); m.startNewSession(); for (int x = 1; x < os400_sessions.size(); x++ ) { String sel = os400_sessions.elementAt(x).toString(); if (!m.frame1.isVisible()) { m.splash.updateProgress(++m.step); m.frame1.setVisible(true); m.splash.setVisible(false); m.frame1.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } m.sessionArgs = new String[NUM_PARMS]; m.parseArgs(sessions.getProperty(sel),m.sessionArgs); m.newSession(sel,m.sessionArgs); } // 2001/09/19 natural computing MR // END } else { m.startNewSession(); } }
char c = event.getActionCommand().charAt(0); if (Character.isISOControl(c)) return; JTextComponent t = getTextComponent(event); if (t != null && t.isEnabled() && t.isEditable()) t.replaceSelection(event.getActionCommand());
JTextComponent target = getTextComponent(event); if ((target != null) && (event != null)) { if ((target.isEditable()) && (target.isEnabled())) { String content = event.getActionCommand(); int mod = event.getModifiers(); if ((content != null) && (content.length() > 0) && (mod & ActionEvent.ALT_MASK) == 0 && (mod & ActionEvent.CTRL_MASK) == 0) { char c = content.charAt(0); if ((c >= 0x20) && (c != 0x7F)) { target.replaceSelection(content); } } } }
public void actionPerformed(ActionEvent event) { // first we filter the following events: // - control characters // - key events with the ALT modifier (FIXME: filter that too!) char c = event.getActionCommand().charAt(0); if (Character.isISOControl(c)) return; JTextComponent t = getTextComponent(event); if (t != null && t.isEnabled() && t.isEditable()) t.replaceSelection(event.getActionCommand()); }
screen.pasteMe(false);
screen.sendKeys(MNEMONIC_PASTE);
private void doPopup (MouseEvent me) { JMenuItem menuItem; Action action; popup = new JPopupMenu(); final Gui5250 g = this; JMenuItem mi; final int pos = screen.getRowColFromPoint(me.getX(),me.getY()) - (screen.getCols()-1); if (!rubberband.isAreaSelected() && screen.isInField(pos,false) ) { action = new AbstractAction(LangTool.getString("popup.copy")) { public void actionPerformed(ActionEvent e) { screen.copyField(pos); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_COPY)); action = new AbstractAction(LangTool.getString("popup.paste")) { public void actionPerformed(ActionEvent e) { screen.pasteMe(false); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_PASTE)); action = new AbstractAction(LangTool.getString("popup.pasteSpecial")) { public void actionPerformed(ActionEvent e) { screen.pasteMe(true); getFocusForMe(); } }; popup.add(action); popup.addSeparator(); } else { action = new AbstractAction(LangTool.getString("popup.copy")) { public void actionPerformed(ActionEvent e) { screen.copyMe(); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_COPY)); action = new AbstractAction(LangTool.getString("popup.paste")) { public void actionPerformed(ActionEvent e) { screen.pasteMe(false); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_PASTE)); action = new AbstractAction(LangTool.getString("popup.pasteSpecial")) { public void actionPerformed(ActionEvent e) { screen.pasteMe(true); getFocusForMe(); } }; popup.add(action); Rectangle workR = new Rectangle(); if (rubberband.isAreaSelected()) { rubberband.getBoundingArea(workR); // get the width and height int ePos = screen.getRowColFromPoint(workR.width , workR.height ); popup.addSeparator(); menuItem = new JMenuItem(LangTool.getString("popup.selectedColumns") + " " + screen.getCol(ePos)); menuItem.setArmed(false); popup.add(menuItem); menuItem = new JMenuItem(LangTool.getString("popup.selectedRows") + " " + screen.getRow(ePos)); menuItem.setArmed(false); popup.add(menuItem); JMenu sumMenu = new JMenu(LangTool.getString("popup.calc")); popup.add(sumMenu); action = new AbstractAction(LangTool.getString("popup.calcGroupCD")) { public void actionPerformed(ActionEvent e) { sumArea(true); } }; sumMenu.add(action); action = new AbstractAction(LangTool.getString("popup.calcGroupDC")) { public void actionPerformed(ActionEvent e) { sumArea(false); } }; sumMenu.add(action); } popup.addSeparator(); action = new AbstractAction(LangTool.getString("popup.printScreen")) { public void actionPerformed(ActionEvent e) { screen.printMe(); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_PRINT_SCREEN)); popup.addSeparator(); JMenu kbMenu = new JMenu(LangTool.getString("popup.keyboard")); popup.add(kbMenu); action = new AbstractAction(LangTool.getString("popup.mapKeys")) { public void actionPerformed(ActionEvent e) { mapMeKeys(); } }; kbMenu.add(action); kbMenu.addSeparator(); action = new AbstractAction(LangTool.getString("key.[attn]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[attn]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_ATTN)); action = new AbstractAction(LangTool.getString("key.[reset]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[reset]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_RESET)); action = new AbstractAction(LangTool.getString("key.[sysreq]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[sysreq]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_SYSREQ)); if (screen.isMessageWait()) { action = new AbstractAction(LangTool.getString("popup.displayMessages")) { public void actionPerformed(ActionEvent e) { vt.systemRequest('4'); } }; kbMenu.add(createMenuItem(action,MNEMONIC_DISP_MESSAGES)); } kbMenu.addSeparator(); action = new AbstractAction(LangTool.getString("key.[dupfield]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[dupfield]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_DUP_FIELD)); action = new AbstractAction(LangTool.getString("key.[help]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[help]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_HELP)); action = new AbstractAction(LangTool.getString("key.[eraseeof]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[eraseeof]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_ERASE_EOF)); action = new AbstractAction(LangTool.getString("key.[field+]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[field+]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_FIELD_PLUS)); action = new AbstractAction(LangTool.getString("key.[field-]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[field-]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_FIELD_MINUS)); action = new AbstractAction(LangTool.getString("key.[newline]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[newline]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_NEW_LINE)); action = new AbstractAction(LangTool.getString("popup.hostPrint")) { public void actionPerformed(ActionEvent e) { vt.hostPrint(1); } }; kbMenu.add(createMenuItem(action,MNEMONIC_PRINT)); createShortCutItems(kbMenu); if (screen.isMessageWait()) { action = new AbstractAction(LangTool.getString("popup.displayMessages")) { public void actionPerformed(ActionEvent e) { vt.systemRequest('4'); } }; popup.add(createMenuItem(action,MNEMONIC_DISP_MESSAGES)); } popup.addSeparator(); action = new AbstractAction(LangTool.getString("popup.hexMap")) { public void actionPerformed(ActionEvent e) { showHexMap(); getFocusForMe(); } }; popup.add(createMenuItem(action,"")); action = new AbstractAction(LangTool.getString("popup.mapKeys")) { public void actionPerformed(ActionEvent e) { mapMeKeys(); getFocusForMe(); } }; popup.add(createMenuItem(action,"")); action = new AbstractAction(LangTool.getString("popup.settings")) { public void actionPerformed(ActionEvent e) { doAttributes(); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_DISP_ATTRIBUTES)); popup.addSeparator(); if (isMacroRunning()) { action = new AbstractAction(LangTool.getString("popup.stopScript")) { public void actionPerformed(ActionEvent e) { setStopMacroRequested(); } }; popup.add(action); } else { JMenu macMenu = new JMenu(LangTool.getString("popup.macros")); if (recording) { action = new AbstractAction(LangTool.getString("popup.stop")) { public void actionPerformed(ActionEvent e) { stopRecordingMe(); getFocusForMe(); } }; } else { action = new AbstractAction(LangTool.getString("popup.record")) { public void actionPerformed(ActionEvent e) { startRecordingMe(); getFocusForMe(); } }; } macMenu.add(action); if (macros.isMacrosExist()) { // this will add a sorted list of the macros to the macro menu addMacros(macMenu); } popup.add(macMenu); } popup.addSeparator(); action = new AbstractAction(LangTool.getString("popup.xtfrFile")) { public void actionPerformed(ActionEvent e) { doMeTransfer(); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_FILE_TRANSFER)); JMenu sendMenu = new JMenu(LangTool.getString("popup.send")); popup.add(sendMenu); action = new AbstractAction(LangTool.getString("popup.email")) { public void actionPerformed(ActionEvent e) { sendScreenEMail(); getFocusForMe(); } }; sendMenu.add(createMenuItem(action,MNEMONIC_E_MAIL)); action = new AbstractAction(LangTool.getString("popup.file")) { public void actionPerformed(ActionEvent e) { sendMeToFile(); } }; sendMenu.add(action); popup.addSeparator(); } action = new AbstractAction(LangTool.getString("popup.connections")) { public void actionPerformed(ActionEvent e) { doConnections(); } }; popup.add(createMenuItem(action,MNEMONIC_OPEN_NEW)); popup.addSeparator(); if (vt.isConnected()) { action = new AbstractAction(LangTool.getString("popup.disconnect")) { public void actionPerformed(ActionEvent e) { changeConnection(); getFocusForMe(); } }; } else { action = new AbstractAction(LangTool.getString("popup.connect")) { public void actionPerformed(ActionEvent e) { changeConnection(); getFocusForMe(); } }; } popup.add(createMenuItem(action,MNEMONIC_TOGGLE_CONNECTION)); action = new AbstractAction(LangTool.getString("popup.close")) { public void actionPerformed(ActionEvent e) { closeSession(); } }; popup.add(createMenuItem(action,MNEMONIC_CLOSE)); popup.show(me.getComponent(), me.getX(),me.getY()); }
screen.copyMe();
screen.sendKeys(MNEMONIC_COPY);
private void doPopup (MouseEvent me) { JMenuItem menuItem; Action action; popup = new JPopupMenu(); final Gui5250 g = this; JMenuItem mi; final int pos = screen.getRowColFromPoint(me.getX(),me.getY()) - (screen.getCols()-1); if (!rubberband.isAreaSelected() && screen.isInField(pos,false) ) { action = new AbstractAction(LangTool.getString("popup.copy")) { public void actionPerformed(ActionEvent e) { screen.copyField(pos); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_COPY)); action = new AbstractAction(LangTool.getString("popup.paste")) { public void actionPerformed(ActionEvent e) { screen.pasteMe(false); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_PASTE)); action = new AbstractAction(LangTool.getString("popup.pasteSpecial")) { public void actionPerformed(ActionEvent e) { screen.pasteMe(true); getFocusForMe(); } }; popup.add(action); popup.addSeparator(); } else { action = new AbstractAction(LangTool.getString("popup.copy")) { public void actionPerformed(ActionEvent e) { screen.copyMe(); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_COPY)); action = new AbstractAction(LangTool.getString("popup.paste")) { public void actionPerformed(ActionEvent e) { screen.pasteMe(false); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_PASTE)); action = new AbstractAction(LangTool.getString("popup.pasteSpecial")) { public void actionPerformed(ActionEvent e) { screen.pasteMe(true); getFocusForMe(); } }; popup.add(action); Rectangle workR = new Rectangle(); if (rubberband.isAreaSelected()) { rubberband.getBoundingArea(workR); // get the width and height int ePos = screen.getRowColFromPoint(workR.width , workR.height ); popup.addSeparator(); menuItem = new JMenuItem(LangTool.getString("popup.selectedColumns") + " " + screen.getCol(ePos)); menuItem.setArmed(false); popup.add(menuItem); menuItem = new JMenuItem(LangTool.getString("popup.selectedRows") + " " + screen.getRow(ePos)); menuItem.setArmed(false); popup.add(menuItem); JMenu sumMenu = new JMenu(LangTool.getString("popup.calc")); popup.add(sumMenu); action = new AbstractAction(LangTool.getString("popup.calcGroupCD")) { public void actionPerformed(ActionEvent e) { sumArea(true); } }; sumMenu.add(action); action = new AbstractAction(LangTool.getString("popup.calcGroupDC")) { public void actionPerformed(ActionEvent e) { sumArea(false); } }; sumMenu.add(action); } popup.addSeparator(); action = new AbstractAction(LangTool.getString("popup.printScreen")) { public void actionPerformed(ActionEvent e) { screen.printMe(); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_PRINT_SCREEN)); popup.addSeparator(); JMenu kbMenu = new JMenu(LangTool.getString("popup.keyboard")); popup.add(kbMenu); action = new AbstractAction(LangTool.getString("popup.mapKeys")) { public void actionPerformed(ActionEvent e) { mapMeKeys(); } }; kbMenu.add(action); kbMenu.addSeparator(); action = new AbstractAction(LangTool.getString("key.[attn]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[attn]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_ATTN)); action = new AbstractAction(LangTool.getString("key.[reset]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[reset]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_RESET)); action = new AbstractAction(LangTool.getString("key.[sysreq]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[sysreq]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_SYSREQ)); if (screen.isMessageWait()) { action = new AbstractAction(LangTool.getString("popup.displayMessages")) { public void actionPerformed(ActionEvent e) { vt.systemRequest('4'); } }; kbMenu.add(createMenuItem(action,MNEMONIC_DISP_MESSAGES)); } kbMenu.addSeparator(); action = new AbstractAction(LangTool.getString("key.[dupfield]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[dupfield]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_DUP_FIELD)); action = new AbstractAction(LangTool.getString("key.[help]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[help]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_HELP)); action = new AbstractAction(LangTool.getString("key.[eraseeof]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[eraseeof]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_ERASE_EOF)); action = new AbstractAction(LangTool.getString("key.[field+]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[field+]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_FIELD_PLUS)); action = new AbstractAction(LangTool.getString("key.[field-]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[field-]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_FIELD_MINUS)); action = new AbstractAction(LangTool.getString("key.[newline]")) { public void actionPerformed(ActionEvent e) { screen.sendKeys("[newline]"); } }; kbMenu.add(createMenuItem(action,MNEMONIC_NEW_LINE)); action = new AbstractAction(LangTool.getString("popup.hostPrint")) { public void actionPerformed(ActionEvent e) { vt.hostPrint(1); } }; kbMenu.add(createMenuItem(action,MNEMONIC_PRINT)); createShortCutItems(kbMenu); if (screen.isMessageWait()) { action = new AbstractAction(LangTool.getString("popup.displayMessages")) { public void actionPerformed(ActionEvent e) { vt.systemRequest('4'); } }; popup.add(createMenuItem(action,MNEMONIC_DISP_MESSAGES)); } popup.addSeparator(); action = new AbstractAction(LangTool.getString("popup.hexMap")) { public void actionPerformed(ActionEvent e) { showHexMap(); getFocusForMe(); } }; popup.add(createMenuItem(action,"")); action = new AbstractAction(LangTool.getString("popup.mapKeys")) { public void actionPerformed(ActionEvent e) { mapMeKeys(); getFocusForMe(); } }; popup.add(createMenuItem(action,"")); action = new AbstractAction(LangTool.getString("popup.settings")) { public void actionPerformed(ActionEvent e) { doAttributes(); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_DISP_ATTRIBUTES)); popup.addSeparator(); if (isMacroRunning()) { action = new AbstractAction(LangTool.getString("popup.stopScript")) { public void actionPerformed(ActionEvent e) { setStopMacroRequested(); } }; popup.add(action); } else { JMenu macMenu = new JMenu(LangTool.getString("popup.macros")); if (recording) { action = new AbstractAction(LangTool.getString("popup.stop")) { public void actionPerformed(ActionEvent e) { stopRecordingMe(); getFocusForMe(); } }; } else { action = new AbstractAction(LangTool.getString("popup.record")) { public void actionPerformed(ActionEvent e) { startRecordingMe(); getFocusForMe(); } }; } macMenu.add(action); if (macros.isMacrosExist()) { // this will add a sorted list of the macros to the macro menu addMacros(macMenu); } popup.add(macMenu); } popup.addSeparator(); action = new AbstractAction(LangTool.getString("popup.xtfrFile")) { public void actionPerformed(ActionEvent e) { doMeTransfer(); getFocusForMe(); } }; popup.add(createMenuItem(action,MNEMONIC_FILE_TRANSFER)); JMenu sendMenu = new JMenu(LangTool.getString("popup.send")); popup.add(sendMenu); action = new AbstractAction(LangTool.getString("popup.email")) { public void actionPerformed(ActionEvent e) { sendScreenEMail(); getFocusForMe(); } }; sendMenu.add(createMenuItem(action,MNEMONIC_E_MAIL)); action = new AbstractAction(LangTool.getString("popup.file")) { public void actionPerformed(ActionEvent e) { sendMeToFile(); } }; sendMenu.add(action); popup.addSeparator(); } action = new AbstractAction(LangTool.getString("popup.connections")) { public void actionPerformed(ActionEvent e) { doConnections(); } }; popup.add(createMenuItem(action,MNEMONIC_OPEN_NEW)); popup.addSeparator(); if (vt.isConnected()) { action = new AbstractAction(LangTool.getString("popup.disconnect")) { public void actionPerformed(ActionEvent e) { changeConnection(); getFocusForMe(); } }; } else { action = new AbstractAction(LangTool.getString("popup.connect")) { public void actionPerformed(ActionEvent e) { changeConnection(); getFocusForMe(); } }; } popup.add(createMenuItem(action,MNEMONIC_TOGGLE_CONNECTION)); action = new AbstractAction(LangTool.getString("popup.close")) { public void actionPerformed(ActionEvent e) { closeSession(); } }; popup.add(createMenuItem(action,MNEMONIC_CLOSE)); popup.show(me.getComponent(), me.getX(),me.getY()); }
screen.pasteMe(false);
screen.sendKeys(MNEMONIC_PASTE);
public void actionPerformed(ActionEvent e) { screen.pasteMe(false); getFocusForMe(); }
screen.copyMe();
screen.sendKeys(MNEMONIC_COPY);
public void actionPerformed(ActionEvent e) { screen.copyMe(); getFocusForMe(); }
stopMacro = false;
stopMacro = !macroRunning;
public void setMacroRunning(boolean mr) { macroRunning = mr; if (macroRunning) screen.setSRIndicatorOn(); else screen.setSRIndicatorOff(); stopMacro = false; }
setMacroRunning(true); macroRunning = false;
setMacroRunning(false);
public void setStopMacroRequested () { setMacroRunning(true); macroRunning = false; }
System.out.println(srcFile + " not found !");
log.warn(srcFile + " not found !");
private void copyConfigs(String sesFile) { /** Copy the config-files to the user's home-dir */ String srcFile = System.getProperty("user.dir") + File.separator + sesFile; String dest = System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator + sesFile; File rmvFile = new File(sesFile); try { FileReader r = new FileReader(srcFile); BufferedReader b = new BufferedReader(r); FileWriter w = new FileWriter(dest); PrintWriter p = new PrintWriter(w); String regel = b.readLine(); while (regel != null) { p.println(regel); regel = b.readLine(); } b.close(); p.close(); rmvFile.delete(); } catch (FileNotFoundException e) { System.out.println(srcFile + " not found !"); } catch (IOException e) { System.out.println("Global io-error !"); } catch (ArrayIndexOutOfBoundsException e) { } }
System.out.println("Global io-error !");
log.warn("Global io-error !");
private void copyConfigs(String sesFile) { /** Copy the config-files to the user's home-dir */ String srcFile = System.getProperty("user.dir") + File.separator + sesFile; String dest = System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator + sesFile; File rmvFile = new File(sesFile); try { FileReader r = new FileReader(srcFile); BufferedReader b = new BufferedReader(r); FileWriter w = new FileWriter(dest); PrintWriter p = new PrintWriter(w); String regel = b.readLine(); while (regel != null) { p.println(regel); regel = b.readLine(); } b.close(); p.close(); rmvFile.delete(); } catch (FileNotFoundException e) { System.out.println(srcFile + " not found !"); } catch (IOException e) { System.out.println("Global io-error !"); } catch (ArrayIndexOutOfBoundsException e) { } }
System.out.println(" Information Message: "
log.info(" Information Message: "
private void loadSettings() { FileInputStream in = null; FileInputStream again = null; settings = new Properties(); // here we will check for a system property is provided first. if (System.getProperties().containsKey("emulator.settingsDirectory")) { settings.setProperty("emulator.settingsDirectory", System.getProperty("emulator.settingsDirectory") + File.separator); checkDirs(); } else { settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); try { in = new FileInputStream(settingsFile); settings.load(in); } catch (FileNotFoundException fnfe) { try { again = new FileInputStream(settingsDirectory() + settingsFile); settings.load(again); } catch (FileNotFoundException fnfea) { System.out.println(" Information Message: " + fnfea.getMessage() + ". The file " + settingsFile + " will be created for first time use."); checkLegacy(); saveSettings(); } catch (IOException ioea) { System.out.println("IO Exception accessing File " + settingsFile + " for the following reason : " + ioea.getMessage()); } catch (SecurityException sea) { System.out.println("Security Exception for file " + settingsFile + " This file can not be " + "accessed because : " + sea.getMessage()); } } catch (IOException ioe) { System.out.println("IO Exception accessing File " + settingsFile + " for the following reason : " + ioe.getMessage()); } catch (SecurityException se) { System.out.println("Security Exception for file " + settingsFile + " This file can not be " + "accessed because : " + se.getMessage()); } } }
System.out.println("IO Exception accessing File "
log.warn("IO Exception accessing File "
private void loadSettings() { FileInputStream in = null; FileInputStream again = null; settings = new Properties(); // here we will check for a system property is provided first. if (System.getProperties().containsKey("emulator.settingsDirectory")) { settings.setProperty("emulator.settingsDirectory", System.getProperty("emulator.settingsDirectory") + File.separator); checkDirs(); } else { settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); try { in = new FileInputStream(settingsFile); settings.load(in); } catch (FileNotFoundException fnfe) { try { again = new FileInputStream(settingsDirectory() + settingsFile); settings.load(again); } catch (FileNotFoundException fnfea) { System.out.println(" Information Message: " + fnfea.getMessage() + ". The file " + settingsFile + " will be created for first time use."); checkLegacy(); saveSettings(); } catch (IOException ioea) { System.out.println("IO Exception accessing File " + settingsFile + " for the following reason : " + ioea.getMessage()); } catch (SecurityException sea) { System.out.println("Security Exception for file " + settingsFile + " This file can not be " + "accessed because : " + sea.getMessage()); } } catch (IOException ioe) { System.out.println("IO Exception accessing File " + settingsFile + " for the following reason : " + ioe.getMessage()); } catch (SecurityException se) { System.out.println("Security Exception for file " + settingsFile + " This file can not be " + "accessed because : " + se.getMessage()); } } }
System.out.println("Security Exception for file "
log.warn("Security Exception for file "
private void loadSettings() { FileInputStream in = null; FileInputStream again = null; settings = new Properties(); // here we will check for a system property is provided first. if (System.getProperties().containsKey("emulator.settingsDirectory")) { settings.setProperty("emulator.settingsDirectory", System.getProperty("emulator.settingsDirectory") + File.separator); checkDirs(); } else { settings.setProperty("emulator.settingsDirectory", System.getProperty("user.home") + File.separator + ".tn5250j" + File.separator); try { in = new FileInputStream(settingsFile); settings.load(in); } catch (FileNotFoundException fnfe) { try { again = new FileInputStream(settingsDirectory() + settingsFile); settings.load(again); } catch (FileNotFoundException fnfea) { System.out.println(" Information Message: " + fnfea.getMessage() + ". The file " + settingsFile + " will be created for first time use."); checkLegacy(); saveSettings(); } catch (IOException ioea) { System.out.println("IO Exception accessing File " + settingsFile + " for the following reason : " + ioea.getMessage()); } catch (SecurityException sea) { System.out.println("Security Exception for file " + settingsFile + " This file can not be " + "accessed because : " + sea.getMessage()); } } catch (IOException ioe) { System.out.println("IO Exception accessing File " + settingsFile + " for the following reason : " + ioe.getMessage()); } catch (SecurityException se) { System.out.println("Security Exception for file " + settingsFile + " This file can not be " + "accessed because : " + se.getMessage()); } } }
out.write(buf.length + 1);
writeLength(out, buf.length + 1);
private static int writeBitString(OutputStream out, BitString bs) throws IOException { byte[] buf = bs.getShiftedByteArray(); out.write(buf.length + 1); out.write(bs.getIgnoredBits()); out.write(buf); return buf.length; }
return buf.length;
return buf.length + 1;
private static int writeBitString(OutputStream out, BitString bs) throws IOException { byte[] buf = bs.getShiftedByteArray(); out.write(buf.length + 1); out.write(bs.getIgnoredBits()); out.write(buf); return buf.length; }
if (nextFreePtr == null) {
if (nextFreePtr.EQ(Address.zero())) {
protected Object alloc(VmClassType<?> vmClass, int alignedSize) { if (nextFreePtr == null) { /* This heap is full */ return null; } final Offset tibOffset = this.tibOffset; final Word headerSize = Word.fromIntZeroExtend(this.headerSize); final Offset flagsOffset = this.flagsOffset; final Offset sizeOffset = this.sizeOffset; Word alignedSizeW = Word.fromIntZeroExtend(alignedSize); final Word totalSize = alignedSizeW.add(headerSize); final Object tib = vmClass.getTIB(); if (tib == null) { throw new IllegalArgumentException("vmClass.TIB is null"); } //final int size = getSize(); Address objectPtr = null; lock(); try { // Search for the first free block that is large enough //Screen.debug("a"); while (objectPtr == null) { final Address ptr = nextFreePtr; final Word objSize = ptr.loadWord(sizeOffset); final Object objVmt = ptr.loadObjectReference(tibOffset); final Address nextPtr = ptr.add(objSize.add(headerSize)); if ((objVmt == FREE) && alignedSizeW.LE(objSize)) { objectPtr = ptr; } else { if (!inHeap(nextPtr)) { // No large enough free space has been found // A collect may recover smaller free spaces in this // heap, but we leave that to a GC iteration. nextFreePtr = null; //Screen.debug("B"); return null; } else { this.nextFreePtr = nextPtr; } } } //Screen.debug("A"); final Word curFreeSize = objectPtr.loadWord(sizeOffset); if (curFreeSize.GT(totalSize)) { // Block is larger then we need, split it up. final Word newFreeSize = curFreeSize.sub(totalSize); /*if (newFreeSize <= headerSize) { Unsafe.debug("Block splitup failed"); Unsafe.debug("\ncurFreeSize "); Unsafe.debug(curFreeSize); Unsafe.debug("\ntotalSize "); Unsafe.debug(totalSize); Unsafe.debug("\nnewFreeSize "); Unsafe.debug(newFreeSize); Unsafe.debug("\nheaderSize "); Unsafe.debug(headerSize); throw new Error("Block splitup failed"); }*/ final Address newFreePtr = objectPtr.add(totalSize); // Set the header for the remaining free block newFreePtr.store(newFreeSize, sizeOffset); newFreePtr.store(0, flagsOffset); newFreePtr.store(ObjectReference.fromObject(FREE), tibOffset); // Set the next free offset nextFreePtr = newFreePtr; } else { // The block is not large enough to split up, make the // new object the size of the free block. alignedSizeW = curFreeSize; } // Create the object header objectPtr.store(alignedSizeW, sizeOffset); objectPtr.store(0, flagsOffset); objectPtr.store(ObjectReference.fromObject(tib), tibOffset); // Mark the object in the allocation bitmap setAllocationBit(objectPtr, true); // Fix the freeSize freeSize = freeSize.sub(alignedSizeW); } finally { unlock(); } // Clear the contents of the object. helper.clear(objectPtr, alignedSize); return objectPtr.toObjectReference().toObject(); }
Address objectPtr = null;
Address objectPtr = Address.zero();
protected Object alloc(VmClassType<?> vmClass, int alignedSize) { if (nextFreePtr == null) { /* This heap is full */ return null; } final Offset tibOffset = this.tibOffset; final Word headerSize = Word.fromIntZeroExtend(this.headerSize); final Offset flagsOffset = this.flagsOffset; final Offset sizeOffset = this.sizeOffset; Word alignedSizeW = Word.fromIntZeroExtend(alignedSize); final Word totalSize = alignedSizeW.add(headerSize); final Object tib = vmClass.getTIB(); if (tib == null) { throw new IllegalArgumentException("vmClass.TIB is null"); } //final int size = getSize(); Address objectPtr = null; lock(); try { // Search for the first free block that is large enough //Screen.debug("a"); while (objectPtr == null) { final Address ptr = nextFreePtr; final Word objSize = ptr.loadWord(sizeOffset); final Object objVmt = ptr.loadObjectReference(tibOffset); final Address nextPtr = ptr.add(objSize.add(headerSize)); if ((objVmt == FREE) && alignedSizeW.LE(objSize)) { objectPtr = ptr; } else { if (!inHeap(nextPtr)) { // No large enough free space has been found // A collect may recover smaller free spaces in this // heap, but we leave that to a GC iteration. nextFreePtr = null; //Screen.debug("B"); return null; } else { this.nextFreePtr = nextPtr; } } } //Screen.debug("A"); final Word curFreeSize = objectPtr.loadWord(sizeOffset); if (curFreeSize.GT(totalSize)) { // Block is larger then we need, split it up. final Word newFreeSize = curFreeSize.sub(totalSize); /*if (newFreeSize <= headerSize) { Unsafe.debug("Block splitup failed"); Unsafe.debug("\ncurFreeSize "); Unsafe.debug(curFreeSize); Unsafe.debug("\ntotalSize "); Unsafe.debug(totalSize); Unsafe.debug("\nnewFreeSize "); Unsafe.debug(newFreeSize); Unsafe.debug("\nheaderSize "); Unsafe.debug(headerSize); throw new Error("Block splitup failed"); }*/ final Address newFreePtr = objectPtr.add(totalSize); // Set the header for the remaining free block newFreePtr.store(newFreeSize, sizeOffset); newFreePtr.store(0, flagsOffset); newFreePtr.store(ObjectReference.fromObject(FREE), tibOffset); // Set the next free offset nextFreePtr = newFreePtr; } else { // The block is not large enough to split up, make the // new object the size of the free block. alignedSizeW = curFreeSize; } // Create the object header objectPtr.store(alignedSizeW, sizeOffset); objectPtr.store(0, flagsOffset); objectPtr.store(ObjectReference.fromObject(tib), tibOffset); // Mark the object in the allocation bitmap setAllocationBit(objectPtr, true); // Fix the freeSize freeSize = freeSize.sub(alignedSizeW); } finally { unlock(); } // Clear the contents of the object. helper.clear(objectPtr, alignedSize); return objectPtr.toObjectReference().toObject(); }
nextFreePtr = null;
nextFreePtr = Address.zero();
protected Object alloc(VmClassType<?> vmClass, int alignedSize) { if (nextFreePtr == null) { /* This heap is full */ return null; } final Offset tibOffset = this.tibOffset; final Word headerSize = Word.fromIntZeroExtend(this.headerSize); final Offset flagsOffset = this.flagsOffset; final Offset sizeOffset = this.sizeOffset; Word alignedSizeW = Word.fromIntZeroExtend(alignedSize); final Word totalSize = alignedSizeW.add(headerSize); final Object tib = vmClass.getTIB(); if (tib == null) { throw new IllegalArgumentException("vmClass.TIB is null"); } //final int size = getSize(); Address objectPtr = null; lock(); try { // Search for the first free block that is large enough //Screen.debug("a"); while (objectPtr == null) { final Address ptr = nextFreePtr; final Word objSize = ptr.loadWord(sizeOffset); final Object objVmt = ptr.loadObjectReference(tibOffset); final Address nextPtr = ptr.add(objSize.add(headerSize)); if ((objVmt == FREE) && alignedSizeW.LE(objSize)) { objectPtr = ptr; } else { if (!inHeap(nextPtr)) { // No large enough free space has been found // A collect may recover smaller free spaces in this // heap, but we leave that to a GC iteration. nextFreePtr = null; //Screen.debug("B"); return null; } else { this.nextFreePtr = nextPtr; } } } //Screen.debug("A"); final Word curFreeSize = objectPtr.loadWord(sizeOffset); if (curFreeSize.GT(totalSize)) { // Block is larger then we need, split it up. final Word newFreeSize = curFreeSize.sub(totalSize); /*if (newFreeSize <= headerSize) { Unsafe.debug("Block splitup failed"); Unsafe.debug("\ncurFreeSize "); Unsafe.debug(curFreeSize); Unsafe.debug("\ntotalSize "); Unsafe.debug(totalSize); Unsafe.debug("\nnewFreeSize "); Unsafe.debug(newFreeSize); Unsafe.debug("\nheaderSize "); Unsafe.debug(headerSize); throw new Error("Block splitup failed"); }*/ final Address newFreePtr = objectPtr.add(totalSize); // Set the header for the remaining free block newFreePtr.store(newFreeSize, sizeOffset); newFreePtr.store(0, flagsOffset); newFreePtr.store(ObjectReference.fromObject(FREE), tibOffset); // Set the next free offset nextFreePtr = newFreePtr; } else { // The block is not large enough to split up, make the // new object the size of the free block. alignedSizeW = curFreeSize; } // Create the object header objectPtr.store(alignedSizeW, sizeOffset); objectPtr.store(0, flagsOffset); objectPtr.store(ObjectReference.fromObject(tib), tibOffset); // Mark the object in the allocation bitmap setAllocationBit(objectPtr, true); // Fix the freeSize freeSize = freeSize.sub(alignedSizeW); } finally { unlock(); } // Clear the contents of the object. helper.clear(objectPtr, alignedSize); return objectPtr.toObjectReference().toObject(); }
Address firstFreePtr = null;
Address firstFreePtr = Address.zero();
protected final void defragment() throws UninterruptiblePragma { final Word size = Word.fromIntZeroExtend(getSize()); final Word headerSize = Word.fromIntZeroExtend(this.headerSize); Word offset = headerSize; final Offset sizeOffset = this.sizeOffset; final Offset tibOffset = this.tibOffset; lock(); try { Address firstFreePtr = null; while (offset.LT(size)) { final Address ptr = start.add(offset); final Word objSize = ptr.loadWord(sizeOffset); final Word nextOffset = offset.add(objSize).add(headerSize); final Object vmt = ptr.loadObjectReference(tibOffset); if ((firstFreePtr == null) && (vmt == FREE)) { firstFreePtr = ptr; } if ((vmt == FREE) && (nextOffset.LT(size))) { final Object nextVmt; final Address nextObjectPtr = start.add(nextOffset); nextVmt = nextObjectPtr.loadObjectReference(tibOffset); if (nextVmt == FREE) { // Combine two free spaces Word nextObjSize = nextObjectPtr.loadWord(sizeOffset); Word newObjSize = objSize.add(headerSize).add(nextObjSize); ptr.store(newObjSize, sizeOffset); // Do not increment offset here, because there may be // another next free object, which we will combine // in the next loop. } else { offset = nextOffset; } } else { offset = nextOffset; } } // Set the address of the next free block, to the first free block this.nextFreePtr = firstFreePtr; } finally { unlock(); } }
try {
public static void main(String[] args) { try { String s = null; s.length(); System.out.println("No throw of NPE: NOK!"); } catch (NullPointerException ex) { System.out.println("catch of NPE: OK! (" + ex + ")"); } }
} catch (NullPointerException ex) { System.out.println("catch of NPE: OK! (" + ex + ")"); }
public static void main(String[] args) { try { String s = null; s.length(); System.out.println("No throw of NPE: NOK!"); } catch (NullPointerException ex) { System.out.println("catch of NPE: OK! (" + ex + ")"); } }
return encoded.array();
byte[] ret = encoded.array(); if (ret.length > len) { byte[] ret2 = new byte[len]; System.arraycopy(ret, 0, ret2, 0, len); ret = ret2; } return ret;
final byte[] encodeText(String text) throws IOException { encoder.reset(); if (!encoder.canEncode(text)) { // Check each character StringBuffer buf = new StringBuffer(); int len = text.length(); for (int i = 0; i < len; i++) { char c = text.charAt(i); if (encoder.canEncode(c)) { buf.append(c); } else { // Replace with character entity reference String hex = Integer.toHexString((int) c); buf.append("&#x"); buf.append(hex); buf.append(';'); } } text = buf.toString(); } ByteBuffer encoded = encoder.encode(CharBuffer.wrap(text)); if (encoded.hasArray()) { return encoded.array(); } encoded.flip(); int len = encoded.limit() - encoded.position(); byte[] ret = new byte[len]; encoded.get(ret, 0, len); return ret; }
int len = encoded.limit() - encoded.position();
final byte[] encodeText(String text) throws IOException { encoder.reset(); if (!encoder.canEncode(text)) { // Check each character StringBuffer buf = new StringBuffer(); int len = text.length(); for (int i = 0; i < len; i++) { char c = text.charAt(i); if (encoder.canEncode(c)) { buf.append(c); } else { // Replace with character entity reference String hex = Integer.toHexString((int) c); buf.append("&#x"); buf.append(hex); buf.append(';'); } } text = buf.toString(); } ByteBuffer encoded = encoder.encode(CharBuffer.wrap(text)); if (encoded.hasArray()) { return encoded.array(); } encoded.flip(); int len = encoded.limit() - encoded.position(); byte[] ret = new byte[len]; encoded.get(ret, 0, len); return ret; }
return ftpFile.getSize();
return ftpFile.size();
public long getLength() { return ftpFile.getSize(); }
fileSystem.cwd(parent.path()); InputStream in = fileSystem.retrieveFileStream(getName()); int i = in.available(); data = new byte[i]; in.read(data);
fileSystem.chdir(parent.path()); data = fileSystem.get(getName());
public synchronized void read(long fileOffset, ByteBuffer dest) throws IOException { try { if(data == null){ synchronized(fileSystem) { fileSystem.cwd(parent.path()); //data = fileSystem.get(getName()); InputStream in = fileSystem.retrieveFileStream(getName()); int i = in.available(); data = new byte[i]; in.read(data); } } int len = dest.remaining(); len = Math.min(len,(int) (data.length - fileOffset)); if(len > 0){ dest.put(data, (int) fileOffset, len); } }catch(Exception e){ throw new IOException("Read error"); } }
private Object get(int index) { Object result = cp[ index]; return result;
private final Object get(int index) { return cp[ index];
private Object get(int index) { Object result = cp[ index]; /* * if (result == null) { System.err.println("Warning: cp[" + index + "] * (tag " + tags[index] + ") returns null"); */ return result; }
public int indexOf(Object object) {
public final int indexOf(Object object) {
public int indexOf(Object object) { for (int i = 0; i < used; i++) { final Object o = cp[ i]; if ((o != null) && (o.equals(object))) { return i; } } return -1; }
if (blink.isSelected()) { changes.firePropertyChange(this,"cursorBlink", getStringProperty("cursorBlink"), "Yes"); setProperty("cursorBlink","Yes"); } else { changes.firePropertyChange(this,"cursorBlink", getStringProperty("cursorBlink"), "No"); setProperty("cursorBlink","No"); }
public void applyAttributes() { if (cFull.isSelected()) { changes.firePropertyChange(this,"cursorSize", getStringProperty("cursorSize"), "Full"); setProperty("cursorSize","Full"); } if (cHalf.isSelected()) { changes.firePropertyChange(this,"cursorSize", getStringProperty("cursorSize"), "Half"); setProperty("cursorSize","Half"); } if (cLine.isSelected()) { changes.firePropertyChange(this,"cursorSize", getStringProperty("cursorSize"), "Line"); setProperty("cursorSize","Line"); } if (chNone.isSelected()) { changes.firePropertyChange(this,"crossHair", getStringProperty("crossHair"), "None"); setProperty("crossHair","None"); } if (chHorz.isSelected()) { changes.firePropertyChange(this,"crossHair", getStringProperty("crossHair"), "Horz"); setProperty("crossHair","Horz"); } if (chVert.isSelected()) { changes.firePropertyChange(this,"crossHair", getStringProperty("crossHair"), "Vert"); setProperty("crossHair","Vert"); } if (chCross.isSelected()) { changes.firePropertyChange(this,"crossHair", getStringProperty("crossHair"), "Both"); setProperty("crossHair","Both"); } if (rulerFixed.isSelected()) { changes.firePropertyChange(this,"rulerFixed", getStringProperty("rulerFixed"), "No"); setProperty("rulerFixed","No"); } else { changes.firePropertyChange(this,"rulerFixed", getStringProperty("rulerFixed"), "Yes"); setProperty("rulerFixed","Yes"); } changes.firePropertyChange(this,"cursorBottOffset", getStringProperty("cursorBottOffset"), cursorBottOffset.getText()); setProperty("cursorBottOffset",cursorBottOffset.getText()); }