rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
m.minor = Minor.Any; | public void read_value(org.omg.CORBA.portable.InputStream input, TypeCode a_type ) throws MARSHAL { try { int kind = a_type.kind().value(); // Fixed needs special handling. if (kind == TCKind._tk_fixed) { BigDecimal dec = BigDecimalHelper.read(input, a_type.fixed_scale()); has = new FixedHolder(dec); } else { has = holderFactory.createHolder(a_type); if (has == null) { // Use the Universal Holder that reads till the end of stream. // This works with the extract/insert pair of the typical // Helper. cdrBufOutput buffer = new cdrBufOutput(); buffer.setOrb(orb); has = new universalHolder(buffer); } } type(a_type); if (!(has instanceof universalHolder) && (kind == TCKind._tk_value_box)) { // The streamable only contains operations for // reading the value, not the value header. Field vField = has.getClass().getField("value"); BoxedValueHelper helper; try { Class helperClass = Class.forName(ObjectCreator.toHelperName(a_type.id())); helper = (BoxedValueHelper) helperClass.newInstance(); } catch (Exception ex) { helper = null; } Object content = Vio.read(input, helper); vField.set(has, content); } else has._read(input); } catch (Exception ex) { MARSHAL m = new MARSHAL(); m.initCause(ex); throw m; } } |
|
if (color == null) g.setColor(t.getSelectionColor()); else g.setColor(color); | Color col = getColor(); if (col == null) col = t.getSelectionColor(); g.setColor(col); | public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent t) { if (p0 == p1) return; Rectangle rect = bounds.getBounds(); if (color == null) g.setColor(t.getSelectionColor()); else g.setColor(color); TextUI ui = t.getUI(); try { Rectangle l0 = ui.modelToView(t, p0, null); Rectangle l1 = ui.modelToView(t, p1, null); // Note: The computed locations may lie outside of the allocation // area if the text is scrolled. if (l0.y == l1.y) { SwingUtilities.computeUnion(l0.x, l0.y, l0.width, l0.height, l1); // Paint only inside the allocation area. SwingUtilities.computeIntersection(rect.x, rect.y, rect.width, rect.height, l1); paintHighlight(g, l1); } else { // 1. The line of p0 is painted from the position of p0 // to the right border. // 2. All lines between the ones where p0 and p1 lie on // are completely highlighted. The allocation area is used to find // out the bounds. // 3. The final line is painted from the left border to the // position of p1. // Highlight first line until the end. // If rect.x is non-zero the calculation will properly adjust the // area to be painted. l0.x -= rect.x; l0.width = rect.width - l0.x - rect.x; paintHighlight(g, l0); int posBelow = Utilities.getPositionBelow(t, p0, l0.x); int p1RowStart = Utilities.getRowStart(t, p1); if (posBelow != -1 && posBelow != p0 && Utilities.getRowStart(t, posBelow) != p1RowStart) { Rectangle grow = ui.modelToView(t, posBelow); grow.x = rect.x; grow.width = rect.width; // Find further lines which have to be highlighted completely. int nextPosBelow = posBelow; while (nextPosBelow != -1 && Utilities.getRowStart(t, nextPosBelow) != p1RowStart) { posBelow = nextPosBelow; nextPosBelow = Utilities.getPositionBelow(t, posBelow, l0.x); if (nextPosBelow == posBelow) break; } // Now posBelow is an offset on the last line which has to be painted // completely. (newPosBelow is on the same line as p1) // Retrieve the rectangle of posBelow and use its y and height // value to calculate the final height of the multiple line // spanning rectangle. Rectangle end = ui.modelToView(t, posBelow); grow.height = end.y + end.height - grow.y; paintHighlight(g, grow); } // Paint last line from its beginning to the position of p1. l1.width = l1.x + l1.width - rect.x; l1.x = rect.x; paintHighlight(g, l1); } } catch (BadLocationException ex) { AssertionError err = new AssertionError("Unexpected bad location exception"); err.initCause(ex); throw err; } } |
paintHighlight(g, l1); | g.fillRect(l1.x, l1.y, l1.width, l1.height); | public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent t) { if (p0 == p1) return; Rectangle rect = bounds.getBounds(); if (color == null) g.setColor(t.getSelectionColor()); else g.setColor(color); TextUI ui = t.getUI(); try { Rectangle l0 = ui.modelToView(t, p0, null); Rectangle l1 = ui.modelToView(t, p1, null); // Note: The computed locations may lie outside of the allocation // area if the text is scrolled. if (l0.y == l1.y) { SwingUtilities.computeUnion(l0.x, l0.y, l0.width, l0.height, l1); // Paint only inside the allocation area. SwingUtilities.computeIntersection(rect.x, rect.y, rect.width, rect.height, l1); paintHighlight(g, l1); } else { // 1. The line of p0 is painted from the position of p0 // to the right border. // 2. All lines between the ones where p0 and p1 lie on // are completely highlighted. The allocation area is used to find // out the bounds. // 3. The final line is painted from the left border to the // position of p1. // Highlight first line until the end. // If rect.x is non-zero the calculation will properly adjust the // area to be painted. l0.x -= rect.x; l0.width = rect.width - l0.x - rect.x; paintHighlight(g, l0); int posBelow = Utilities.getPositionBelow(t, p0, l0.x); int p1RowStart = Utilities.getRowStart(t, p1); if (posBelow != -1 && posBelow != p0 && Utilities.getRowStart(t, posBelow) != p1RowStart) { Rectangle grow = ui.modelToView(t, posBelow); grow.x = rect.x; grow.width = rect.width; // Find further lines which have to be highlighted completely. int nextPosBelow = posBelow; while (nextPosBelow != -1 && Utilities.getRowStart(t, nextPosBelow) != p1RowStart) { posBelow = nextPosBelow; nextPosBelow = Utilities.getPositionBelow(t, posBelow, l0.x); if (nextPosBelow == posBelow) break; } // Now posBelow is an offset on the last line which has to be painted // completely. (newPosBelow is on the same line as p1) // Retrieve the rectangle of posBelow and use its y and height // value to calculate the final height of the multiple line // spanning rectangle. Rectangle end = ui.modelToView(t, posBelow); grow.height = end.y + end.height - grow.y; paintHighlight(g, grow); } // Paint last line from its beginning to the position of p1. l1.width = l1.x + l1.width - rect.x; l1.x = rect.x; paintHighlight(g, l1); } } catch (BadLocationException ex) { AssertionError err = new AssertionError("Unexpected bad location exception"); err.initCause(ex); throw err; } } |
l0.x -= rect.x; l0.width = rect.width - l0.x - rect.x; paintHighlight(g, l0); int posBelow = Utilities.getPositionBelow(t, p0, l0.x); int p1RowStart = Utilities.getRowStart(t, p1); if (posBelow != -1 && posBelow != p0 && Utilities.getRowStart(t, posBelow) != p1RowStart) { Rectangle grow = ui.modelToView(t, posBelow); grow.x = rect.x; grow.width = rect.width; int nextPosBelow = posBelow; while (nextPosBelow != -1 && Utilities.getRowStart(t, nextPosBelow) != p1RowStart) { posBelow = nextPosBelow; nextPosBelow = Utilities.getPositionBelow(t, posBelow, l0.x); if (nextPosBelow == posBelow) break; } Rectangle end = ui.modelToView(t, posBelow); grow.height = end.y + end.height - grow.y; paintHighlight(g, grow); } l1.width = l1.x + l1.width - rect.x; l1.x = rect.x; paintHighlight(g, l1); | int firstLineWidth = rect.x + rect.width - l0.x; g.fillRect(l0.x, l0.y, firstLineWidth, l0.height); if (l0.y + l0.height != l1.y) { g.fillRect(rect.x, l0.y + l0.height, rect.width, l1.y - l0.y - l0.height); } g.fillRect(rect.x, l1.y, l1.x - rect.x, l1.height); | public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent t) { if (p0 == p1) return; Rectangle rect = bounds.getBounds(); if (color == null) g.setColor(t.getSelectionColor()); else g.setColor(color); TextUI ui = t.getUI(); try { Rectangle l0 = ui.modelToView(t, p0, null); Rectangle l1 = ui.modelToView(t, p1, null); // Note: The computed locations may lie outside of the allocation // area if the text is scrolled. if (l0.y == l1.y) { SwingUtilities.computeUnion(l0.x, l0.y, l0.width, l0.height, l1); // Paint only inside the allocation area. SwingUtilities.computeIntersection(rect.x, rect.y, rect.width, rect.height, l1); paintHighlight(g, l1); } else { // 1. The line of p0 is painted from the position of p0 // to the right border. // 2. All lines between the ones where p0 and p1 lie on // are completely highlighted. The allocation area is used to find // out the bounds. // 3. The final line is painted from the left border to the // position of p1. // Highlight first line until the end. // If rect.x is non-zero the calculation will properly adjust the // area to be painted. l0.x -= rect.x; l0.width = rect.width - l0.x - rect.x; paintHighlight(g, l0); int posBelow = Utilities.getPositionBelow(t, p0, l0.x); int p1RowStart = Utilities.getRowStart(t, p1); if (posBelow != -1 && posBelow != p0 && Utilities.getRowStart(t, posBelow) != p1RowStart) { Rectangle grow = ui.modelToView(t, posBelow); grow.x = rect.x; grow.width = rect.width; // Find further lines which have to be highlighted completely. int nextPosBelow = posBelow; while (nextPosBelow != -1 && Utilities.getRowStart(t, nextPosBelow) != p1RowStart) { posBelow = nextPosBelow; nextPosBelow = Utilities.getPositionBelow(t, posBelow, l0.x); if (nextPosBelow == posBelow) break; } // Now posBelow is an offset on the last line which has to be painted // completely. (newPosBelow is on the same line as p1) // Retrieve the rectangle of posBelow and use its y and height // value to calculate the final height of the multiple line // spanning rectangle. Rectangle end = ui.modelToView(t, posBelow); grow.height = end.y + end.height - grow.y; paintHighlight(g, grow); } // Paint last line from its beginning to the position of p1. l1.width = l1.x + l1.width - rect.x; l1.x = rect.x; paintHighlight(g, l1); } } catch (BadLocationException ex) { AssertionError err = new AssertionError("Unexpected bad location exception"); err.initCause(ex); throw err; } } |
AssertionError err = new AssertionError("Unexpected bad location exception"); err.initCause(ex); throw err; | public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent t) { if (p0 == p1) return; Rectangle rect = bounds.getBounds(); if (color == null) g.setColor(t.getSelectionColor()); else g.setColor(color); TextUI ui = t.getUI(); try { Rectangle l0 = ui.modelToView(t, p0, null); Rectangle l1 = ui.modelToView(t, p1, null); // Note: The computed locations may lie outside of the allocation // area if the text is scrolled. if (l0.y == l1.y) { SwingUtilities.computeUnion(l0.x, l0.y, l0.width, l0.height, l1); // Paint only inside the allocation area. SwingUtilities.computeIntersection(rect.x, rect.y, rect.width, rect.height, l1); paintHighlight(g, l1); } else { // 1. The line of p0 is painted from the position of p0 // to the right border. // 2. All lines between the ones where p0 and p1 lie on // are completely highlighted. The allocation area is used to find // out the bounds. // 3. The final line is painted from the left border to the // position of p1. // Highlight first line until the end. // If rect.x is non-zero the calculation will properly adjust the // area to be painted. l0.x -= rect.x; l0.width = rect.width - l0.x - rect.x; paintHighlight(g, l0); int posBelow = Utilities.getPositionBelow(t, p0, l0.x); int p1RowStart = Utilities.getRowStart(t, p1); if (posBelow != -1 && posBelow != p0 && Utilities.getRowStart(t, posBelow) != p1RowStart) { Rectangle grow = ui.modelToView(t, posBelow); grow.x = rect.x; grow.width = rect.width; // Find further lines which have to be highlighted completely. int nextPosBelow = posBelow; while (nextPosBelow != -1 && Utilities.getRowStart(t, nextPosBelow) != p1RowStart) { posBelow = nextPosBelow; nextPosBelow = Utilities.getPositionBelow(t, posBelow, l0.x); if (nextPosBelow == posBelow) break; } // Now posBelow is an offset on the last line which has to be painted // completely. (newPosBelow is on the same line as p1) // Retrieve the rectangle of posBelow and use its y and height // value to calculate the final height of the multiple line // spanning rectangle. Rectangle end = ui.modelToView(t, posBelow); grow.height = end.y + end.height - grow.y; paintHighlight(g, grow); } // Paint last line from its beginning to the position of p1. l1.width = l1.x + l1.width - rect.x; l1.x = rect.x; paintHighlight(g, l1); } } catch (BadLocationException ex) { AssertionError err = new AssertionError("Unexpected bad location exception"); err.initCause(ex); throw err; } } |
|
throw new InternalError(); | Color col = getColor(); if (col == null) col = c.getSelectionColor(); g.setColor(col); Rectangle rect = null; if (p0 == view.getStartOffset() && p1 == view.getEndOffset()) { rect = bounds instanceof Rectangle ? (Rectangle) bounds : bounds.getBounds(); } else { try { Shape s = view.modelToView(p0, Position.Bias.Forward, p1, Position.Bias.Backward, bounds); rect = s instanceof Rectangle ? (Rectangle) s : s.getBounds(); } catch (BadLocationException ex) { } } if (rect != null) { g.fillRect(rect.x, rect.y, rect.width, rect.height); } return rect; | public Shape paintLayer(Graphics g, int p0, int p1, Shape bounds, JTextComponent c, View view) { throw new InternalError(); } |
public HighlightEntry(int p0, int p1, Highlighter.HighlightPainter painter) | public HighlightEntry(Position p0, Position p1, Highlighter.HighlightPainter painter) | public HighlightEntry(int p0, int p1, Highlighter.HighlightPainter painter) { this.p0 = p0; this.p1 = p1; this.painter = painter; } |
return p1; | return p1.getOffset(); | public int getEndOffset() { return p1; } |
return p0; | return p0.getOffset(); | public int getStartOffset() { return p0; } |
HighlightEntry entry = new HighlightEntry(p0, p1, painter); | HighlightEntry entry; Document doc = textComponent.getDocument(); Position pos0 = doc.createPosition(p0); Position pos1 = doc.createPosition(p1); if (getDrawsLayeredHighlights() && painter instanceof LayerPainter) entry = new LayerHighlightEntry(pos0, pos1, painter); else entry = new HighlightEntry(pos0, pos1, painter); | public Object addHighlight(int p0, int p1, Highlighter.HighlightPainter painter) throws BadLocationException { checkPositions(p0, p1); HighlightEntry entry = new HighlightEntry(p0, p1, painter); highlights.add(entry); textComponent.getUI().damageRange(textComponent, p0, p1); return entry; } |
int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; | Document doc = textComponent.getDocument(); | public void changeHighlight(Object tag, int n0, int n1) throws BadLocationException { int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; // Prevent useless write & repaint operations. if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; TextUI ui = textComponent.getUI(); // Special situation where the old area has to be cleared simply. if (n0 == n1) ui.damageRange(textComponent, o0, o1); // Calculates the areas where a change is really neccessary else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) { // [fds, fde) - the first damage region // [sds, sde] - the second damage region int fds, sds; int fde, sde; // Calculate first damaged region. if(o0 < n0) { // Damaged region will be cleared as // the old highlight region starts first. fds = o0; fde = n0; } else { // Damaged region will be painted as // the new highlight region starts first. fds = n0; fde = o0; } if (o1 < n1) { // Final region will be painted as the // old highlight region finishes first sds = o1; sde = n1; } else { // Final region will be cleared as the // new highlight region finishes first. sds = n1; sde = o1; } // If there is no undamaged region in between // call damageRange only once. if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } } else { // The two regions do not overlap. So mark // both areas as damaged. ui.damageRange(textComponent, o0, o1); ui.damageRange(textComponent, n0, n1); } } |
if (n0 == n1) ui.damageRange(textComponent, o0, o1); else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) | if (tag instanceof LayerHighlightEntry) { LayerHighlightEntry le = (LayerHighlightEntry) tag; Rectangle r = le.paintRect; if (r.width > 0 && r.height > 0) textComponent.repaint(r.x, r.y, r.width, r.height); r.width = 0; r.height = 0; le.p0 = doc.createPosition(n0); le.p1 = doc.createPosition(n1); ui.damageRange(textComponent, Math.min(n0, n1), Math.max(n0, n1)); } else if (tag instanceof HighlightEntry) | public void changeHighlight(Object tag, int n0, int n1) throws BadLocationException { int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; // Prevent useless write & repaint operations. if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; TextUI ui = textComponent.getUI(); // Special situation where the old area has to be cleared simply. if (n0 == n1) ui.damageRange(textComponent, o0, o1); // Calculates the areas where a change is really neccessary else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) { // [fds, fde) - the first damage region // [sds, sde] - the second damage region int fds, sds; int fde, sde; // Calculate first damaged region. if(o0 < n0) { // Damaged region will be cleared as // the old highlight region starts first. fds = o0; fde = n0; } else { // Damaged region will be painted as // the new highlight region starts first. fds = n0; fde = o0; } if (o1 < n1) { // Final region will be painted as the // old highlight region finishes first sds = o1; sde = n1; } else { // Final region will be cleared as the // new highlight region finishes first. sds = n1; sde = o1; } // If there is no undamaged region in between // call damageRange only once. if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } } else { // The two regions do not overlap. So mark // both areas as damaged. ui.damageRange(textComponent, o0, o1); ui.damageRange(textComponent, n0, n1); } } |
int fds, sds; int fde, sde; if(o0 < n0) | HighlightEntry e = (HighlightEntry) tag; int p0 = e.getStartOffset(); int p1 = e.getEndOffset(); if (p0 == n0) | public void changeHighlight(Object tag, int n0, int n1) throws BadLocationException { int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; // Prevent useless write & repaint operations. if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; TextUI ui = textComponent.getUI(); // Special situation where the old area has to be cleared simply. if (n0 == n1) ui.damageRange(textComponent, o0, o1); // Calculates the areas where a change is really neccessary else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) { // [fds, fde) - the first damage region // [sds, sde] - the second damage region int fds, sds; int fde, sde; // Calculate first damaged region. if(o0 < n0) { // Damaged region will be cleared as // the old highlight region starts first. fds = o0; fde = n0; } else { // Damaged region will be painted as // the new highlight region starts first. fds = n0; fde = o0; } if (o1 < n1) { // Final region will be painted as the // old highlight region finishes first sds = o1; sde = n1; } else { // Final region will be cleared as the // new highlight region finishes first. sds = n1; sde = o1; } // If there is no undamaged region in between // call damageRange only once. if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } } else { // The two regions do not overlap. So mark // both areas as damaged. ui.damageRange(textComponent, o0, o1); ui.damageRange(textComponent, n0, n1); } } |
fds = o0; fde = n0; | ui.damageRange(textComponent, Math.min(p1, n1), Math.max(p1, n1)); | public void changeHighlight(Object tag, int n0, int n1) throws BadLocationException { int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; // Prevent useless write & repaint operations. if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; TextUI ui = textComponent.getUI(); // Special situation where the old area has to be cleared simply. if (n0 == n1) ui.damageRange(textComponent, o0, o1); // Calculates the areas where a change is really neccessary else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) { // [fds, fde) - the first damage region // [sds, sde] - the second damage region int fds, sds; int fde, sde; // Calculate first damaged region. if(o0 < n0) { // Damaged region will be cleared as // the old highlight region starts first. fds = o0; fde = n0; } else { // Damaged region will be painted as // the new highlight region starts first. fds = n0; fde = o0; } if (o1 < n1) { // Final region will be painted as the // old highlight region finishes first sds = o1; sde = n1; } else { // Final region will be cleared as the // new highlight region finishes first. sds = n1; sde = o1; } // If there is no undamaged region in between // call damageRange only once. if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } } else { // The two regions do not overlap. So mark // both areas as damaged. ui.damageRange(textComponent, o0, o1); ui.damageRange(textComponent, n0, n1); } } |
else | else if (n1 == p1) | public void changeHighlight(Object tag, int n0, int n1) throws BadLocationException { int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; // Prevent useless write & repaint operations. if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; TextUI ui = textComponent.getUI(); // Special situation where the old area has to be cleared simply. if (n0 == n1) ui.damageRange(textComponent, o0, o1); // Calculates the areas where a change is really neccessary else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) { // [fds, fde) - the first damage region // [sds, sde] - the second damage region int fds, sds; int fde, sde; // Calculate first damaged region. if(o0 < n0) { // Damaged region will be cleared as // the old highlight region starts first. fds = o0; fde = n0; } else { // Damaged region will be painted as // the new highlight region starts first. fds = n0; fde = o0; } if (o1 < n1) { // Final region will be painted as the // old highlight region finishes first sds = o1; sde = n1; } else { // Final region will be cleared as the // new highlight region finishes first. sds = n1; sde = o1; } // If there is no undamaged region in between // call damageRange only once. if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } } else { // The two regions do not overlap. So mark // both areas as damaged. ui.damageRange(textComponent, o0, o1); ui.damageRange(textComponent, n0, n1); } } |
fds = n0; fde = o0; } if (o1 < n1) { sds = o1; sde = n1; } else { sds = n1; sde = o1; } if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } | ui.damageRange(textComponent, Math.min(p0, n0), Math.max(p0, n0)); | public void changeHighlight(Object tag, int n0, int n1) throws BadLocationException { int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; // Prevent useless write & repaint operations. if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; TextUI ui = textComponent.getUI(); // Special situation where the old area has to be cleared simply. if (n0 == n1) ui.damageRange(textComponent, o0, o1); // Calculates the areas where a change is really neccessary else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) { // [fds, fde) - the first damage region // [sds, sde] - the second damage region int fds, sds; int fde, sde; // Calculate first damaged region. if(o0 < n0) { // Damaged region will be cleared as // the old highlight region starts first. fds = o0; fde = n0; } else { // Damaged region will be painted as // the new highlight region starts first. fds = n0; fde = o0; } if (o1 < n1) { // Final region will be painted as the // old highlight region finishes first sds = o1; sde = n1; } else { // Final region will be cleared as the // new highlight region finishes first. sds = n1; sde = o1; } // If there is no undamaged region in between // call damageRange only once. if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } } else { // The two regions do not overlap. So mark // both areas as damaged. ui.damageRange(textComponent, o0, o1); ui.damageRange(textComponent, n0, n1); } } |
ui.damageRange(textComponent, o0, o1); | ui.damageRange(textComponent, p0, p1); | public void changeHighlight(Object tag, int n0, int n1) throws BadLocationException { int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; // Prevent useless write & repaint operations. if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; TextUI ui = textComponent.getUI(); // Special situation where the old area has to be cleared simply. if (n0 == n1) ui.damageRange(textComponent, o0, o1); // Calculates the areas where a change is really neccessary else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) { // [fds, fde) - the first damage region // [sds, sde] - the second damage region int fds, sds; int fde, sde; // Calculate first damaged region. if(o0 < n0) { // Damaged region will be cleared as // the old highlight region starts first. fds = o0; fde = n0; } else { // Damaged region will be painted as // the new highlight region starts first. fds = n0; fde = o0; } if (o1 < n1) { // Final region will be painted as the // old highlight region finishes first sds = o1; sde = n1; } else { // Final region will be cleared as the // new highlight region finishes first. sds = n1; sde = o1; } // If there is no undamaged region in between // call damageRange only once. if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } } else { // The two regions do not overlap. So mark // both areas as damaged. ui.damageRange(textComponent, o0, o1); ui.damageRange(textComponent, n0, n1); } } |
e.p0 = doc.createPosition(n0); e.p1 = doc.createPosition(n1); } | public void changeHighlight(Object tag, int n0, int n1) throws BadLocationException { int o0, o1; checkPositions(n0, n1); HighlightEntry entry = (HighlightEntry) tag; o0 = entry.p0; o1 = entry.p1; // Prevent useless write & repaint operations. if (o0 == n0 && o1 == n1) return; entry.p0 = n0; entry.p1 = n1; TextUI ui = textComponent.getUI(); // Special situation where the old area has to be cleared simply. if (n0 == n1) ui.damageRange(textComponent, o0, o1); // Calculates the areas where a change is really neccessary else if ((o1 > n0 && o1 <= n1) || (n1 > o0 && n1 <= o1)) { // [fds, fde) - the first damage region // [sds, sde] - the second damage region int fds, sds; int fde, sde; // Calculate first damaged region. if(o0 < n0) { // Damaged region will be cleared as // the old highlight region starts first. fds = o0; fde = n0; } else { // Damaged region will be painted as // the new highlight region starts first. fds = n0; fde = o0; } if (o1 < n1) { // Final region will be painted as the // old highlight region finishes first sds = o1; sde = n1; } else { // Final region will be cleared as the // new highlight region finishes first. sds = n1; sde = o1; } // If there is no undamaged region in between // call damageRange only once. if (fde == sds) ui.damageRange(textComponent, fds, sde); else { if (fds != fde) ui.damageRange(textComponent, fds, fde); if (sds != sde) ui.damageRange(textComponent, sds, sde); } } else { // The two regions do not overlap. So mark // both areas as damaged. ui.damageRange(textComponent, o0, o1); ui.damageRange(textComponent, n0, n1); } } |
|
entry.painter.paint(g, entry.p0, entry.p1, bounds, textComponent); | if (! (entry instanceof LayerHighlightEntry)) entry.painter.paint(g, entry.getStartOffset(), entry.getEndOffset(), bounds, textComponent); | public void paint(Graphics g) { int size = highlights.size(); // Check if there are any highlights. if (size == 0) return; // Prepares the rectangle of the inner drawing area. Insets insets = textComponent.getInsets(); Shape bounds = new Rectangle(insets.left, insets.top, textComponent.getWidth() - insets.left - insets.right, textComponent.getHeight() - insets.top - insets.bottom); for (int index = 0; index < size; ++index) { HighlightEntry entry = (HighlightEntry) highlights.get(index); entry.painter.paint(g, entry.p0, entry.p1, bounds, textComponent); } } |
throws NotImplementedException | public void paintLayeredHighlights(Graphics g, int p0, int p1, Shape viewBounds, JTextComponent editor, View view) throws NotImplementedException { // TODO: Implement this properly. } |
|
for (Iterator i = highlights.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof LayerHighlightEntry) { LayerHighlightEntry entry = (LayerHighlightEntry) o; int start = entry.getStartOffset(); int end = entry.getEndOffset(); if ((p0 < start && p1 > start) || (p0 >= start && p0 < end)) entry.paintLayeredHighlight(g, p0, p1, viewBounds, editor, view); } } | public void paintLayeredHighlights(Graphics g, int p0, int p1, Shape viewBounds, JTextComponent editor, View view) throws NotImplementedException { // TODO: Implement this properly. } |
|
int minX = 0; int maxX = 0; int minY = 0; int maxY = 0; int p0 = -1; int p1 = -1; for (Iterator i = highlights.iterator(); i.hasNext();) { HighlightEntry e = (HighlightEntry) i.next(); if (e instanceof LayerHighlightEntry) { LayerHighlightEntry le = (LayerHighlightEntry) e; Rectangle r = le.paintRect; minX = Math.min(r.x, minX); maxX = Math.max(r.x + r.width, maxX); minY = Math.min(r.y, minY); maxY = Math.max(r.y + r.height, maxY); } else { if (p0 == -1 || p1 == -1) { p0 = e.getStartOffset(); p1 = e.getEndOffset(); } else { p0 = Math.min(p0, e.getStartOffset()); p1 = Math.max(p1, e.getEndOffset()); } } if (minX != maxX && minY != maxY) textComponent.repaint(minX, minY, maxX - minX, maxY - minY); if (p0 != -1 && p1 != -1) { TextUI ui = textComponent.getUI(); ui.damageRange(textComponent, p0, p1); } } | public void removeAllHighlights() { highlights.clear(); } |
|
HighlightEntry entry = (HighlightEntry) tag; textComponent.getUI().damageRange(textComponent, entry.p0, entry.p1); | public void removeHighlight(Object tag) { highlights.remove(tag); HighlightEntry entry = (HighlightEntry) tag; textComponent.getUI().damageRange(textComponent, entry.p0, entry.p1); } |
|
log.debug("paint from screen"); | protected void paintComponent(Graphics g) { log.debug("paint from screen"); if (bi == null) { checkOffScreenImage(); }// screen.paintComponent3(g); Graphics2D g2 = (Graphics2D) g; // Rectangle r = g.getClipBounds(); g2.setColor(bi.colorBg); g2.fillRect(0, 0, getWidth(), getHeight()); bi.drawImageBuffer(g2); if (rubberband.isAreaSelected() && !rubberband.isDragging()) { rubberband.erase(); rubberband.draw(); } keyPad.repaint(); } |
|
repaint(); | screen.repaintScreen(); | public void resizeMe() {// screen.setBounds(getDrawingBounds()); //this is from screen5250 screen.setCursorActive(false); Rectangle r = getDrawingBounds(); if (bi != null) bi.resizeScreenArea(r.width, r.height); repaint();// screen.repaintScreen(); screen.setCursorActive(true); } |
pattern = applyLocalizedPattern (pattern, localChars, standardChars); | pattern = translateLocalizedPattern(pattern, localChars, standardChars); | public void applyLocalizedPattern(String pattern) { String localChars = formatData.getLocalPatternChars(); pattern = applyLocalizedPattern (pattern, localChars, standardChars); applyPattern(pattern); } |
FieldSizePair current = null; | CompiledField current = null; | private void compileFormat(String pattern) { // Any alphabetical characters are treated as pattern characters // unless enclosed in single quotes. char thisChar; int pos; int field; FieldSizePair current = null; for (int i=0; i<pattern.length(); i++) { thisChar = pattern.charAt(i); field = formatData.getLocalPatternChars().indexOf(thisChar); if (field == -1) { current = null; if ((thisChar >= 'A' && thisChar <= 'Z') || (thisChar >= 'a' && thisChar <= 'z')) { // Not a valid letter tokens.add(new FieldSizePair(-1,0)); } else if (thisChar == '\'') { // Quoted text section; skip to next single quote pos = pattern.indexOf('\'',i+1); if (pos == -1) { // This ought to be an exception, but spec does not // let us throw one. tokens.add(new FieldSizePair(-1,0)); } if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) { tokens.add(pattern.substring(i+1,pos+1)); } else { tokens.add(pattern.substring(i+1,pos)); } i = pos; } else { // A special character tokens.add(new Character(thisChar)); } } else { // A valid field if ((current != null) && (field == current.field)) { current.size++; } else { current = new FieldSizePair(field,1); tokens.add(current); } } } } |
field = formatData.getLocalPatternChars().indexOf(thisChar); | field = standardChars.indexOf(thisChar); | private void compileFormat(String pattern) { // Any alphabetical characters are treated as pattern characters // unless enclosed in single quotes. char thisChar; int pos; int field; FieldSizePair current = null; for (int i=0; i<pattern.length(); i++) { thisChar = pattern.charAt(i); field = formatData.getLocalPatternChars().indexOf(thisChar); if (field == -1) { current = null; if ((thisChar >= 'A' && thisChar <= 'Z') || (thisChar >= 'a' && thisChar <= 'z')) { // Not a valid letter tokens.add(new FieldSizePair(-1,0)); } else if (thisChar == '\'') { // Quoted text section; skip to next single quote pos = pattern.indexOf('\'',i+1); if (pos == -1) { // This ought to be an exception, but spec does not // let us throw one. tokens.add(new FieldSizePair(-1,0)); } if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) { tokens.add(pattern.substring(i+1,pos+1)); } else { tokens.add(pattern.substring(i+1,pos)); } i = pos; } else { // A special character tokens.add(new Character(thisChar)); } } else { // A valid field if ((current != null) && (field == current.field)) { current.size++; } else { current = new FieldSizePair(field,1); tokens.add(current); } } } } |
tokens.add(new FieldSizePair(-1,0)); | throw new IllegalArgumentException("Invalid letter " + thisChar + "encountered at character " + i + "."); | private void compileFormat(String pattern) { // Any alphabetical characters are treated as pattern characters // unless enclosed in single quotes. char thisChar; int pos; int field; FieldSizePair current = null; for (int i=0; i<pattern.length(); i++) { thisChar = pattern.charAt(i); field = formatData.getLocalPatternChars().indexOf(thisChar); if (field == -1) { current = null; if ((thisChar >= 'A' && thisChar <= 'Z') || (thisChar >= 'a' && thisChar <= 'z')) { // Not a valid letter tokens.add(new FieldSizePair(-1,0)); } else if (thisChar == '\'') { // Quoted text section; skip to next single quote pos = pattern.indexOf('\'',i+1); if (pos == -1) { // This ought to be an exception, but spec does not // let us throw one. tokens.add(new FieldSizePair(-1,0)); } if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) { tokens.add(pattern.substring(i+1,pos+1)); } else { tokens.add(pattern.substring(i+1,pos)); } i = pos; } else { // A special character tokens.add(new Character(thisChar)); } } else { // A valid field if ((current != null) && (field == current.field)) { current.size++; } else { current = new FieldSizePair(field,1); tokens.add(current); } } } } |
tokens.add(new FieldSizePair(-1,0)); | throw new IllegalArgumentException("Quotes starting at character " + i + " not closed."); | private void compileFormat(String pattern) { // Any alphabetical characters are treated as pattern characters // unless enclosed in single quotes. char thisChar; int pos; int field; FieldSizePair current = null; for (int i=0; i<pattern.length(); i++) { thisChar = pattern.charAt(i); field = formatData.getLocalPatternChars().indexOf(thisChar); if (field == -1) { current = null; if ((thisChar >= 'A' && thisChar <= 'Z') || (thisChar >= 'a' && thisChar <= 'z')) { // Not a valid letter tokens.add(new FieldSizePair(-1,0)); } else if (thisChar == '\'') { // Quoted text section; skip to next single quote pos = pattern.indexOf('\'',i+1); if (pos == -1) { // This ought to be an exception, but spec does not // let us throw one. tokens.add(new FieldSizePair(-1,0)); } if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) { tokens.add(pattern.substring(i+1,pos+1)); } else { tokens.add(pattern.substring(i+1,pos)); } i = pos; } else { // A special character tokens.add(new Character(thisChar)); } } else { // A valid field if ((current != null) && (field == current.field)) { current.size++; } else { current = new FieldSizePair(field,1); tokens.add(current); } } } } |
current = new FieldSizePair(field,1); | current = new CompiledField(field,1,thisChar); | private void compileFormat(String pattern) { // Any alphabetical characters are treated as pattern characters // unless enclosed in single quotes. char thisChar; int pos; int field; FieldSizePair current = null; for (int i=0; i<pattern.length(); i++) { thisChar = pattern.charAt(i); field = formatData.getLocalPatternChars().indexOf(thisChar); if (field == -1) { current = null; if ((thisChar >= 'A' && thisChar <= 'Z') || (thisChar >= 'a' && thisChar <= 'z')) { // Not a valid letter tokens.add(new FieldSizePair(-1,0)); } else if (thisChar == '\'') { // Quoted text section; skip to next single quote pos = pattern.indexOf('\'',i+1); if (pos == -1) { // This ought to be an exception, but spec does not // let us throw one. tokens.add(new FieldSizePair(-1,0)); } if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) { tokens.add(pattern.substring(i+1,pos+1)); } else { tokens.add(pattern.substring(i+1,pos)); } i = pos; } else { // A special character tokens.add(new Character(thisChar)); } } else { // A valid field if ((current != null) && (field == current.field)) { current.size++; } else { current = new FieldSizePair(field,1); tokens.add(current); } } } } |
if (o instanceof FieldSizePair) | if (o instanceof CompiledField) | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
FieldSizePair p = (FieldSizePair) o; | CompiledField cf = (CompiledField) o; | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
switch (p.field) | switch (cf.getField()) | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
if (p.size == 2) | if (cf.getSize() == 2) | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); | withLeadingZeros (calendar.get (Calendar.YEAR), cf.getSize(), buffer); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) | if (cf.getSize() < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, cf.getSize(), buffer); else if (cf.getSize() < 4) | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); | withLeadingZeros (calendar.get (Calendar.DATE), cf.getSize(), buffer); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
p.size, buffer); | cf.getSize(), buffer); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); | withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), cf.getSize(), buffer); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); | withLeadingZeros (calendar.get (Calendar.MILLISECOND), cf.getSize(), buffer); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
if (p.size < 4) | if (cf.getSize() < 4) | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); | withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), cf.getSize(), buffer); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); | withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, cf.getSize(), buffer); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); | withLeadingZeros (calendar.get (Calendar.HOUR), cf.getSize(), buffer); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); | String zoneID = zone.getDisplayName (isDST, cf.getSize() > 3 ? TimeZone.LONG : TimeZone.SHORT); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
throw new IllegalArgumentException ("Illegal pattern character " + p.field); | throw new IllegalArgumentException ("Illegal pattern character " + cf.getCharacter()); | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
|| p.field == pos.getField())) | || cf.getField() == pos.getField())) | private void formatWithAttribute(Date date, FormatBuffer buffer, FieldPosition pos) { String temp; AttributedCharacterIterator.Attribute attribute; calendar.setTime(date); // go through vector, filling in fields where applicable, else toString Iterator iter = tokens.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof FieldSizePair) { FieldSizePair p = (FieldSizePair) o; int beginIndex = buffer.length(); switch (p.field) { case ERA_FIELD: buffer.append (formatData.eras[calendar.get (Calendar.ERA)], DateFormat.Field.ERA); break; case YEAR_FIELD: // If we have two digits, then we truncate. Otherwise, we // use the size of the pattern, and zero pad. buffer.setDefaultAttribute (DateFormat.Field.YEAR); if (p.size == 2) { temp = String.valueOf (calendar.get (Calendar.YEAR)); buffer.append (temp.substring (temp.length() - 2)); } else withLeadingZeros (calendar.get (Calendar.YEAR), p.size, buffer); break; case MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MONTH); if (p.size < 3) withLeadingZeros (calendar.get (Calendar.MONTH) + 1, p.size, buffer); else if (p.size < 4) buffer.append (formatData.shortMonths[calendar.get (Calendar.MONTH)]); else buffer.append (formatData.months[calendar.get (Calendar.MONTH)]); break; case DATE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_MONTH); withLeadingZeros (calendar.get (Calendar.DATE), p.size, buffer); break; case HOUR_OF_DAY1_FIELD: // 1-24 buffer.setDefaultAttribute(DateFormat.Field.HOUR_OF_DAY1); withLeadingZeros ( ((calendar.get (Calendar.HOUR_OF_DAY) + 23) % 24) + 1, p.size, buffer); break; case HOUR_OF_DAY0_FIELD: // 0-23 buffer.setDefaultAttribute (DateFormat.Field.HOUR_OF_DAY0); withLeadingZeros (calendar.get (Calendar.HOUR_OF_DAY), p.size, buffer); break; case MINUTE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MINUTE); withLeadingZeros (calendar.get (Calendar.MINUTE), p.size, buffer); break; case SECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.SECOND); withLeadingZeros(calendar.get (Calendar.SECOND), p.size, buffer); break; case MILLISECOND_FIELD: buffer.setDefaultAttribute (DateFormat.Field.MILLISECOND); withLeadingZeros (calendar.get (Calendar.MILLISECOND), p.size, buffer); break; case DAY_OF_WEEK_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK); if (p.size < 4) buffer.append (formatData.shortWeekdays[calendar.get (Calendar.DAY_OF_WEEK)]); else buffer.append (formatData.weekdays[calendar.get (Calendar.DAY_OF_WEEK)]); break; case DAY_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_YEAR); withLeadingZeros (calendar.get (Calendar.DAY_OF_YEAR), p.size, buffer); break; case DAY_OF_WEEK_IN_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.DAY_OF_WEEK_IN_MONTH); withLeadingZeros (calendar.get (Calendar.DAY_OF_WEEK_IN_MONTH), p.size, buffer); break; case WEEK_OF_YEAR_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_YEAR); withLeadingZeros (calendar.get (Calendar.WEEK_OF_YEAR), p.size, buffer); break; case WEEK_OF_MONTH_FIELD: buffer.setDefaultAttribute (DateFormat.Field.WEEK_OF_MONTH); withLeadingZeros (calendar.get (Calendar.WEEK_OF_MONTH), p.size, buffer); break; case AM_PM_FIELD: buffer.setDefaultAttribute (DateFormat.Field.AM_PM); buffer.append (formatData.ampms[calendar.get (Calendar.AM_PM)]); break; case HOUR1_FIELD: // 1-12 buffer.setDefaultAttribute (DateFormat.Field.HOUR1); withLeadingZeros (((calendar.get (Calendar.HOUR) + 11) % 12) + 1, p.size, buffer); break; case HOUR0_FIELD: // 0-11 buffer.setDefaultAttribute (DateFormat.Field.HOUR0); withLeadingZeros (calendar.get (Calendar.HOUR), p.size, buffer); break; case TIMEZONE_FIELD: buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE); TimeZone zone = calendar.getTimeZone(); boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0; // FIXME: XXX: This should be a localized time zone. String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT); buffer.append (zoneID); break; default: throw new IllegalArgumentException ("Illegal pattern character " + p.field); } if (pos != null && (buffer.getDefaultAttribute() == pos.getFieldAttribute() || p.field == pos.getField())) { pos.setBeginIndex(beginIndex); pos.setEndIndex(buffer.length()); } } else { buffer.append(o.toString(), null); } } } |
catch (IllegalArgumentException e) { throw new InvalidObjectException("The stream pattern was invalid."); } } | private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); if (serialVersionOnStream < 1) { computeCenturyStart (); serialVersionOnStream = 1; } else // Ensure that defaultCentury gets set. set2DigitYearStart(defaultCenturyStart); // Set up items normally taken care of by the constructor. tokens = new ArrayList(); compileFormat(pattern); } |
|
return applyLocalizedPattern (pattern, standardChars, localChars); | return translateLocalizedPattern(pattern, standardChars, localChars); | public String toLocalizedPattern() { String localChars = formatData.getLocalPatternChars(); return applyLocalizedPattern (pattern, standardChars, localChars); } |
StringBuffer output = new StringBuffer(); Iterator i = tokens.iterator(); while (i.hasNext()) { output.append(i.next().toString()); } | StringBuilder output = new StringBuilder(getClass().getName()); output.append("[tokens="); output.append(tokens); output.append(", formatData="); output.append(formatData); output.append(", defaultCenturyStart="); output.append(defaultCenturyStart); output.append(", defaultCentury="); output.append(defaultCentury); output.append(", pattern="); output.append(pattern); output.append(", serialVersionOnStream="); output.append(serialVersionOnStream); output.append(", standardChars="); output.append(standardChars); output.append("]"); | public String toString() { StringBuffer output = new StringBuffer(); Iterator i = tokens.iterator(); while (i.hasNext()) { output.append(i.next().toString()); } return output.toString(); } |
leadPath = null; | public void clearSelection() { selection = null; } |
|
void setParentImpl(View p) | private void setParentImpl(View p) | void setParentImpl(View p) { if (p != null) { Component c = getComponent(); p.getContainer().add(c); } else { Component c = getComponent(); Container parent = c.getParent(); parent.remove(c); comp = null; } } |
super.setParent(p); | void setParentImpl(View p) { if (p != null) { Component c = getComponent(); p.getContainer().add(c); } else { Component c = getComponent(); Container parent = c.getParent(); parent.remove(c); comp = null; } } |
|
log.info("New session Manager initialized"); | private void initialize() { sessions = new Sessions(); configs = new Vector(3); } |
|
public boolean canImport (JComponent c, DataFlavor[] flavors) | public boolean canImport(JComponent c, DataFlavor[] flavors) throws NotImplementedException | public boolean canImport (JComponent c, DataFlavor[] flavors) { return false; } |
throws NotImplementedException | protected Transferable createTransferable(JComponent c) { return null; } |
|
public void exportAsDrag (JComponent c, InputEvent e, int action) | public void exportAsDrag(JComponent c, InputEvent e, int action) throws NotImplementedException | public void exportAsDrag (JComponent c, InputEvent e, int action) { // TODO: Implement this properly } |
protected void exportDone (JComponent c, Transferable data, int action) | protected void exportDone(JComponent c, Transferable data, int action) throws NotImplementedException | protected void exportDone (JComponent c, Transferable data, int action) { // TODO: Implement this properly } |
throws NotImplementedException | public void exportToClipboard(JComponent c, Clipboard clip, int action) { // TODO: Implement this properly } |
|
public boolean importData (JComponent c, Transferable t) | public boolean importData(JComponent c, Transferable t) throws NotImplementedException | public boolean importData (JComponent c, Transferable t) { return false; } |
if (groupObject != null) { if (groupMemberHash.add(groupObject)) { groupObject.addMemberObject(this); return groupObject; } else { Log.error("Can't add to group. already a member of the group" + groupObject.getName()); | if (groupMemberHash.add(groupObject)) { groupObject.addMemberObject(this); return groupObject; } else { Log.errorln("Can't add to group. already a member of the group" + groupObject.getName()); | public Group addToGroup(Group groupObject) { if (groupObject != null) { if (groupMemberHash.add(groupObject)) { //add in successful groupObject.addMemberObject(this); return groupObject; // bad, should return based on success of adding } else { Log.error("Can't add to group. already a member of the group" + groupObject.getName()); return null; } } else { Log.error("Error: the group object to add to is null"); return null; } } |
} } else { Log.error("Error: the group object to add to is null"); return null; | public Group addToGroup(Group groupObject) { if (groupObject != null) { if (groupMemberHash.add(groupObject)) { //add in successful groupObject.addMemberObject(this); return groupObject; // bad, should return based on success of adding } else { Log.error("Can't add to group. already a member of the group" + groupObject.getName()); return null; } } else { Log.error("Error: the group object to add to is null"); return null; } } |
|
return cloneObj; | protected Object clone () throws CloneNotSupportedException{ //shallow copy for fields BaseObject cloneObj = (BaseObject) super.clone(); // deep copy the attriOrder synchronized (this.attribOrder) { synchronized (cloneObj.attribOrder) { cloneObj.attribOrder = Collections.synchronizedList(new ArrayList()); int stop = this.attribOrder.size(); for (int i = 0; i < stop; i++) { cloneObj.attribOrder.add(new String((String) this.attribOrder.get(i))); } } } // XMLAttributes Clone, deep copy synchronized (this.attribHash) { synchronized (cloneObj.attribHash) { cloneObj.attribHash = new Hashtable(); Enumeration keys = this.attribHash.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); XMLAttribute XMLAttributeValue = (XMLAttribute) this.attribHash.get(key); cloneObj.attribHash.put(key, XMLAttributeValue.clone()); } } } return cloneObj; } |
|
if (sPrettyXDFOutput) writeOut(outputstream, indent); | if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); | private String dealWithClosingGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(this.openGroupNodeHash) { Iterator iter = this.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); this.openGroupNodeHash.remove(openGroup); // peel off some indent indent = indent.substring(0,indent.length() - sPrettyXDFOutputIndentation.length()); } } } } return indent; } |
if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); | if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); | private String dealWithClosingGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(this.openGroupNodeHash) { Iterator iter = this.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); this.openGroupNodeHash.remove(openGroup); // peel off some indent indent = indent.substring(0,indent.length() - sPrettyXDFOutputIndentation.length()); } } } } return indent; } |
indent = indent.substring(0,indent.length() - sPrettyXDFOutputIndentation.length()); | indent = indent.substring(0,indent.length() - Specification.getInstance().getPrettyXDFOutputIndentation().length()); | private String dealWithClosingGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(this.openGroupNodeHash) { Iterator iter = this.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); this.openGroupNodeHash.remove(openGroup); // peel off some indent indent = indent.substring(0,indent.length() - sPrettyXDFOutputIndentation.length()); } } } } return indent; } |
newIndent.append(sPrettyXDFOutputIndentation); | newIndent.append(Specification.getInstance().getPrettyXDFOutputIndentation()); | private String dealWithOpeningGroupNodes (BaseObject obj, OutputStream outputstream, String indent) { StringBuffer newIndent = new StringBuffer(indent); // Should *both* groupMemberHash and openGroupNodeHash be synchronized?? synchronized(obj.groupMemberHash) { synchronized(this.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(!this.openGroupNodeHash.contains(memberGroup)) { // its *not* already open, so we bump up the indentation, // open it and add it to the open group node list. newIndent.append(sPrettyXDFOutputIndentation); memberGroup.toXMLOutputStream(outputstream, new Hashtable(), newIndent.toString(), true, null, null); this.openGroupNodeHash.add(memberGroup); } } } } return newIndent.toString(); } |
int size = attribHash.size(); for (int i = 0; i < size; i++) { String attribName = (String) attribOrder.get(i); XMLAttribute obj = (XMLAttribute) attribHash.get(attribName); if (obj != null && obj.attribValue != null) { if ( obj.attribType == Constants.STRING_TYPE) { | synchronized (attribHash) { int size = attribHash.size(); for (int i = 0; i < size; i++) { String attribName = (String) attribOrder.get(i); XMLAttribute obj = (XMLAttribute) attribHash.get(attribName); if (obj != null && obj.attribValue != null) { if ( obj.attribType == Constants.STRING_TYPE) { | protected Hashtable getXMLInfo () { Hashtable xmlInfo = new Hashtable(); ArrayList attribList = new ArrayList(); ArrayList objRefList = new ArrayList(); int size = attribHash.size(); for (int i = 0; i < size; i++) { String attribName = (String) attribOrder.get(i); XMLAttribute obj = (XMLAttribute) attribHash.get(attribName); if (obj != null && obj.attribValue != null) { if ( obj.attribType == Constants.STRING_TYPE) { if (attribName.equals(sPCDATAAttribute)) { xmlInfo.put("PCDATA", obj.attribValue); } else { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); attribList.add(item); } } else { if(obj.attribType == Constants.NUMBER_TYPE || obj.attribType == Constants.STRING_OR_NUMBER_TYPE) { //it's an attribute of Number type Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue.toString()); attribList.add(item); } else {// add to list if it is not an empty list -k.z. if ((obj.attribType !=Constants.LIST_TYPE) || (((List)obj.attribValue).size()!=0)) { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); item.put("type", obj.attribType); objRefList.add(item); } } } } } xmlInfo.put("attribList", attribList); xmlInfo.put("childObjList", objRefList); return xmlInfo; } |
if (attribName.equals(sPCDATAAttribute)) { xmlInfo.put("PCDATA", obj.attribValue); } else { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); attribList.add(item); } } else { if(obj.attribType == Constants.NUMBER_TYPE || obj.attribType == Constants.STRING_OR_NUMBER_TYPE) { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue.toString()); attribList.add(item); } else { if ((obj.attribType !=Constants.LIST_TYPE) || (((List)obj.attribValue).size()!=0)) { | if (attribName.equals(Specification.getInstance().getPCDATAAttribute())) { xmlInfo.put("PCDATA", obj.attribValue); }else { | protected Hashtable getXMLInfo () { Hashtable xmlInfo = new Hashtable(); ArrayList attribList = new ArrayList(); ArrayList objRefList = new ArrayList(); int size = attribHash.size(); for (int i = 0; i < size; i++) { String attribName = (String) attribOrder.get(i); XMLAttribute obj = (XMLAttribute) attribHash.get(attribName); if (obj != null && obj.attribValue != null) { if ( obj.attribType == Constants.STRING_TYPE) { if (attribName.equals(sPCDATAAttribute)) { xmlInfo.put("PCDATA", obj.attribValue); } else { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); attribList.add(item); } } else { if(obj.attribType == Constants.NUMBER_TYPE || obj.attribType == Constants.STRING_OR_NUMBER_TYPE) { //it's an attribute of Number type Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue.toString()); attribList.add(item); } else {// add to list if it is not an empty list -k.z. if ((obj.attribType !=Constants.LIST_TYPE) || (((List)obj.attribValue).size()!=0)) { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); item.put("type", obj.attribType); objRefList.add(item); } } } } } xmlInfo.put("attribList", attribList); xmlInfo.put("childObjList", objRefList); return xmlInfo; } |
item.put("type", obj.attribType); objRefList.add(item); | attribList.add(item); } } else { if(obj.attribType == Constants.NUMBER_TYPE || obj.attribType == Constants.STRING_OR_NUMBER_TYPE) { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue.toString()); attribList.add(item); } else { if ((obj.attribType !=Constants.LIST_TYPE) || (((List)obj.attribValue).size()!=0)) { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); item.put("type", obj.attribType); objRefList.add(item); } | protected Hashtable getXMLInfo () { Hashtable xmlInfo = new Hashtable(); ArrayList attribList = new ArrayList(); ArrayList objRefList = new ArrayList(); int size = attribHash.size(); for (int i = 0; i < size; i++) { String attribName = (String) attribOrder.get(i); XMLAttribute obj = (XMLAttribute) attribHash.get(attribName); if (obj != null && obj.attribValue != null) { if ( obj.attribType == Constants.STRING_TYPE) { if (attribName.equals(sPCDATAAttribute)) { xmlInfo.put("PCDATA", obj.attribValue); } else { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); attribList.add(item); } } else { if(obj.attribType == Constants.NUMBER_TYPE || obj.attribType == Constants.STRING_OR_NUMBER_TYPE) { //it's an attribute of Number type Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue.toString()); attribList.add(item); } else {// add to list if it is not an empty list -k.z. if ((obj.attribType !=Constants.LIST_TYPE) || (((List)obj.attribValue).size()!=0)) { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); item.put("type", obj.attribType); objRefList.add(item); } } } } } xmlInfo.put("attribList", attribList); xmlInfo.put("childObjList", objRefList); return xmlInfo; } |
} | protected Hashtable getXMLInfo () { Hashtable xmlInfo = new Hashtable(); ArrayList attribList = new ArrayList(); ArrayList objRefList = new ArrayList(); int size = attribHash.size(); for (int i = 0; i < size; i++) { String attribName = (String) attribOrder.get(i); XMLAttribute obj = (XMLAttribute) attribHash.get(attribName); if (obj != null && obj.attribValue != null) { if ( obj.attribType == Constants.STRING_TYPE) { if (attribName.equals(sPCDATAAttribute)) { xmlInfo.put("PCDATA", obj.attribValue); } else { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); attribList.add(item); } } else { if(obj.attribType == Constants.NUMBER_TYPE || obj.attribType == Constants.STRING_OR_NUMBER_TYPE) { //it's an attribute of Number type Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue.toString()); attribList.add(item); } else {// add to list if it is not an empty list -k.z. if ((obj.attribType !=Constants.LIST_TYPE) || (((List)obj.attribValue).size()!=0)) { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); item.put("type", obj.attribType); objRefList.add(item); } } } } } xmlInfo.put("attribList", attribList); xmlInfo.put("childObjList", objRefList); return xmlInfo; } |
|
xmlInfo.put("attribList", attribList); xmlInfo.put("childObjList", objRefList); return xmlInfo; | xmlInfo.put("attribList", attribList); xmlInfo.put("childObjList", objRefList); } return xmlInfo; | protected Hashtable getXMLInfo () { Hashtable xmlInfo = new Hashtable(); ArrayList attribList = new ArrayList(); ArrayList objRefList = new ArrayList(); int size = attribHash.size(); for (int i = 0; i < size; i++) { String attribName = (String) attribOrder.get(i); XMLAttribute obj = (XMLAttribute) attribHash.get(attribName); if (obj != null && obj.attribValue != null) { if ( obj.attribType == Constants.STRING_TYPE) { if (attribName.equals(sPCDATAAttribute)) { xmlInfo.put("PCDATA", obj.attribValue); } else { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); attribList.add(item); } } else { if(obj.attribType == Constants.NUMBER_TYPE || obj.attribType == Constants.STRING_OR_NUMBER_TYPE) { //it's an attribute of Number type Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue.toString()); attribList.add(item); } else {// add to list if it is not an empty list -k.z. if ((obj.attribType !=Constants.LIST_TYPE) || (((List)obj.attribValue).size()!=0)) { Hashtable item = new Hashtable(); item.put("name", attribName); item.put("value", obj.attribValue); item.put("type", obj.attribType); objRefList.add(item); } } } } } xmlInfo.put("attribList", attribList); xmlInfo.put("childObjList", objRefList); return xmlInfo; } |
int size = attribOrder.size(); for (int i = 0; i < size; i++) { attribute = attribOrder.get(i); obj = InitAttributeTable.get(attribute); | if (obj != null) { XMLAttribute toRemove = (XMLAttribute) attribHash.remove(attribute); attribHash.put(attribute, new XMLAttribute(obj, toRemove.getAttribType())); } | protected void hashtableInitXDFAttributes (Hashtable InitAttributeTable) { Object attribute; Object obj; int size = attribOrder.size(); for (int i = 0; i < size; i++) { attribute = attribOrder.get(i); obj = InitAttributeTable.get(attribute); // only if object exists if (obj != null) { XMLAttribute toRemove = (XMLAttribute) attribHash.remove(attribute); attribHash.put(attribute, new XMLAttribute(obj, toRemove.getAttribType())); } } } |
if (obj != null) { XMLAttribute toRemove = (XMLAttribute) attribHash.remove(attribute); attribHash.put(attribute, new XMLAttribute(obj, toRemove.getAttribType())); | protected void hashtableInitXDFAttributes (Hashtable InitAttributeTable) { Object attribute; Object obj; int size = attribOrder.size(); for (int i = 0; i < size; i++) { attribute = attribOrder.get(i); obj = InitAttributeTable.get(attribute); // only if object exists if (obj != null) { XMLAttribute toRemove = (XMLAttribute) attribHash.remove(attribute); attribHash.put(attribute, new XMLAttribute(obj, toRemove.getAttribType())); } } } |
|
if ( (groupObject != null) && groupMemberHash.contains(groupObject)) | if ( groupMemberHash.contains(groupObject)) | public boolean isGroupMember(Group groupObject) { if ( (groupObject != null) && groupMemberHash.contains(groupObject)) return true; else return false; } |
if (groupObject != null) { | public Group removeFromGroup (Group groupObject) { if (groupObject != null) { if (groupMemberHash.contains(groupObject)) { //this object does belong to the indicated Group object groupObject.removeMemberObject((Object) this); groupMemberHash.remove(groupObject); return groupObject; } else { Log.error("Can't delete from group. not a member of the group" + groupObject.getName()); return null; } } else { Log.error("Error: The group to add to is null"); return null; } } |
|
Log.error("Can't delete from group. not a member of the group" + | Log.errorln("Can't delete from group. not a member of the group" + | public Group removeFromGroup (Group groupObject) { if (groupObject != null) { if (groupMemberHash.contains(groupObject)) { //this object does belong to the indicated Group object groupObject.removeMemberObject((Object) this); groupMemberHash.remove(groupObject); return groupObject; } else { Log.error("Can't delete from group. not a member of the group" + groupObject.getName()); return null; } } else { Log.error("Error: The group to add to is null"); return null; } } |
} else { Log.error("Error: The group to add to is null"); return null; } | public Group removeFromGroup (Group groupObject) { if (groupObject != null) { if (groupMemberHash.contains(groupObject)) { //this object does belong to the indicated Group object groupObject.removeMemberObject((Object) this); groupMemberHash.remove(groupObject); return groupObject; } else { Log.error("Can't delete from group. not a member of the group" + groupObject.getName()); return null; } } else { Log.error("Error: The group to add to is null"); return null; } } |
|
if (fromList != null) { if ( what != null) { int index = fromList.indexOf(what); if (index !=-1) { fromList.remove(index); return true; } else { Log.warn("warn: can't find object in" + listName + | int index = fromList.indexOf(what); if (index !=-1) { fromList.remove(index); return true; } else { Log.warn("warn: can't find object in" + listName + | protected boolean removeFromList ( Object what, List fromList, String listName ) { if (fromList != null) { if ( what != null) { int index = fromList.indexOf(what); if (index !=-1) { //object to be removed is found in the list fromList.remove(index); return true; } else { //cant find the object in the list Log.warn("warn: can't find object in" + listName + ", ignoring remove"); return false; } } else { //object to remove is null Log.error("Error: object to remove is null"); return false; } } else { //the list to remove from is null Log.error("Error: Passed list to remove from is null, no object to remove"); return false; } } |
return false; } } else { Log.error("Error: object to remove is null"); return false; } } else { Log.error("Error: Passed list to remove from is null, no object to remove"); | protected boolean removeFromList ( Object what, List fromList, String listName ) { if (fromList != null) { if ( what != null) { int index = fromList.indexOf(what); if (index !=-1) { //object to be removed is found in the list fromList.remove(index); return true; } else { //cant find the object in the list Log.warn("warn: can't find object in" + listName + ", ignoring remove"); return false; } } else { //object to remove is null Log.error("Error: object to remove is null"); return false; } } else { //the list to remove from is null Log.error("Error: Passed list to remove from is null, no object to remove"); return false; } } |
|
if (attrs != null) { int size = attrs.getLength(); for (int i = 0; i < size; i++) { String name = attrs.getName(i); String value = attrs.getValue(i); if (this.attribHash.containsKey(name)) { ((XMLAttribute) this.attribHash.get(name)).setAttribValue(value); } else Log.errorln("Error: cant set XMLAttribute:["+name+"], doesnt exist in object:"+this); } } | synchronized (attribHash) { if (attrs != null) { int size = attrs.getLength(); for (int i = 0; i < size; i++) { String name = attrs.getName(i); String value = attrs.getValue(i); if (name != null && value != null) ((XMLAttribute) this.attribHash.get(name)).setAttribValue(value); } } } | protected void setXMLAttributes (AttributeList attrs) { // set object attributes from an AttributeList if (attrs != null) { // whip thru the list, setting each value int size = attrs.getLength(); for (int i = 0; i < size; i++) { String name = attrs.getName(i); String value = attrs.getValue(i); if (this.attribHash.containsKey(name)) { ((XMLAttribute) this.attribHash.get(name)).setAttribValue(value); } else Log.errorln("Error: cant set XMLAttribute:["+name+"], doesnt exist in object:"+this); } } } |
String nodeNameString = this.classXDFNodeName; | synchronized (attribHash) { String nodeNameString = this.classXDFNodeName; | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
} if (nodeNameString != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent); if ( nodeNameString.equals(sXDFStructureNodeName) && !XMLDeclAttribs.isEmpty() ) nodeNameString = sXDFRootNodeName; writeOut(outputstream,"<" + nodeNameString); } Hashtable xmlInfo = getXMLInfo(); ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); synchronized(attribs) { int size = attribs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
|
int size = childObjs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) childObjs.get(i); | if (nodeNameString != null) { | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
if (item.get("type") == Constants.LIST_TYPE) { | if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
List objectList = (List) item.get("value"); synchronized(objectList) { Iterator iter = objectList.iterator(); while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { | if ( nodeNameString.equals(Specification.getInstance().getXDFStructureNodeName()) && !XMLDeclAttribs.isEmpty() ) nodeNameString = Specification.getInstance().getXDFRootNodeName(); writeOut(outputstream,"<" + nodeNameString); } Hashtable xmlInfo = getXMLInfo(); ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); synchronized(attribs) { int size = attribs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) attribs.get(i); writeOut(outputstream, " "+ item.get("name") + "=\"" + item.get("value") + "\""); } } ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { if (nodeNameString != null) { writeOut(outputstream, ">"); if ((Specification.getInstance().isPrettyXDFOutput()) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } int size = childObjs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { List objectList = (List) item.get("value"); synchronized(objectList) { Iterator iter = objectList.iterator(); while (iter.hasNext()) { BaseObject containedObj = (BaseObject) iter.next(); if (containedObj != null) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); containedObj.toXMLOutputStream(outputstream, new Hashtable(), newindent); } } } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { synchronized(containedObj) { | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
String newindent = indent + sPrettyXDFOutputIndentation; | String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
else if (item.get("type") == Constants.OBJECT_TYPE) | if(pcdata != null) { writeOut(outputstream, pcdata); }; if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { synchronized(containedObj) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(outputstream, new Hashtable(), newindent); } } | if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent + Specification.getInstance().getPrettyXDFOutputIndentation()); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); } if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (Specification.getInstance().isPrettyXDFOutput() && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { writeOut(outputstream, ">"); | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
Log.errorln("Weird error: unknown XML attribute type for item:"+item); | writeOut(outputstream, "/>"); | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
if(pcdata != null) { writeOut(outputstream, pcdata); }; if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { writeOut(outputstream, ">"); } else { writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); | if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); } | public void toXMLOutputStream ( 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() ) nodeNameString = sXDFRootNodeName; 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) { int size = attribs.size(); for (int i = 0; i < 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"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { writeOut(outputstream, ">"); if ((sPrettyXDFOutput) && (pcdata == null)) writeOut(outputstream, Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < 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 (?) indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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) { indent = dealWithOpeningGroupNodes(containedObj, outputstream, indent); indent = dealWithClosingGroupNodes(containedObj, outputstream, indent); String newindent = indent + sPrettyXDFOutputIndentation; containedObj.toXMLOutputStream(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); }; // 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) { if (sPrettyXDFOutput) writeOut(outputstream, indent + sPrettyXDFOutputIndentation); writeOut(outputstream, "<" + noChildObjectNodeName + "/>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputstream, indent); if (sPrettyXDFOutput && pcdata == null) writeOut(outputstream, indent); if (!dontCloseNode) writeOut(outputstream, "</"+nodeNameString+">"); } } else { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) writeOut(outputstream, ">"); } else { // no sub-objects, just close this node writeOut(outputstream, "/>"); } } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } |
writeOut(outputstream, " version=\"" + sXMLSpecVersion + "\""); | writeOut(outputstream, " version=\"" + Specification.getInstance().getXMLSpecVersion() + "\""); | private void writeXMLDeclToOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs ) { // initial statement writeOut(outputstream, "<?xml"); writeOut(outputstream, " version=\"" + sXMLSpecVersion + "\""); // print attributes Enumeration keys = XMLDeclAttribs.keys(); while ( keys.hasMoreElements() ) { String attribName = (String) keys.nextElement(); if (attribName.equals("version") ) { Log.errorln("XMLDeclAttrib hash has version attribute, not allowed and ignoring."); } else if ( attribName.equals("dtdName") || attribName.equals("rootName") ) { // skip over it } else writeOut(outputstream, " " + attribName + "=\"" + XMLDeclAttribs.get(attribName) + "\""); } writeOut(outputstream, " ?>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); // Print the DOCTYPE DECL only if right info exists if (XMLDeclAttribs.containsKey("rootName") && XMLDeclAttribs.containsKey("dtdName")) { // print the DOCTYPE DECL IF its a structure node if(classXDFNodeName != null && classXDFNodeName.equals(sXDFStructureNodeName) ) { writeOut(outputstream, "<!DOCTYPE " + XMLDeclAttribs.get("rootName") + " SYSTEM \"" + XMLDeclAttribs.get("dtdName") + "\">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } else Log.errorln("Passed XMLDeclAttributes table lacks either dtdName, rootName entries, ignoring DOCTYPE line printout"); } |
if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); | if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); | private void writeXMLDeclToOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs ) { // initial statement writeOut(outputstream, "<?xml"); writeOut(outputstream, " version=\"" + sXMLSpecVersion + "\""); // print attributes Enumeration keys = XMLDeclAttribs.keys(); while ( keys.hasMoreElements() ) { String attribName = (String) keys.nextElement(); if (attribName.equals("version") ) { Log.errorln("XMLDeclAttrib hash has version attribute, not allowed and ignoring."); } else if ( attribName.equals("dtdName") || attribName.equals("rootName") ) { // skip over it } else writeOut(outputstream, " " + attribName + "=\"" + XMLDeclAttribs.get(attribName) + "\""); } writeOut(outputstream, " ?>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); // Print the DOCTYPE DECL only if right info exists if (XMLDeclAttribs.containsKey("rootName") && XMLDeclAttribs.containsKey("dtdName")) { // print the DOCTYPE DECL IF its a structure node if(classXDFNodeName != null && classXDFNodeName.equals(sXDFStructureNodeName) ) { writeOut(outputstream, "<!DOCTYPE " + XMLDeclAttribs.get("rootName") + " SYSTEM \"" + XMLDeclAttribs.get("dtdName") + "\">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } else Log.errorln("Passed XMLDeclAttributes table lacks either dtdName, rootName entries, ignoring DOCTYPE line printout"); } |
if(classXDFNodeName != null && classXDFNodeName.equals(sXDFStructureNodeName) ) { writeOut(outputstream, "<!DOCTYPE " + XMLDeclAttribs.get("rootName") + " SYSTEM \"" | if(classXDFNodeName != null && classXDFNodeName.equals(Specification.getInstance().getXDFStructureNodeName()) ) { writeOut(outputstream, "<!DOCTYPE " + XMLDeclAttribs.get("rootName") + " SYSTEM \"" | private void writeXMLDeclToOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs ) { // initial statement writeOut(outputstream, "<?xml"); writeOut(outputstream, " version=\"" + sXMLSpecVersion + "\""); // print attributes Enumeration keys = XMLDeclAttribs.keys(); while ( keys.hasMoreElements() ) { String attribName = (String) keys.nextElement(); if (attribName.equals("version") ) { Log.errorln("XMLDeclAttrib hash has version attribute, not allowed and ignoring."); } else if ( attribName.equals("dtdName") || attribName.equals("rootName") ) { // skip over it } else writeOut(outputstream, " " + attribName + "=\"" + XMLDeclAttribs.get(attribName) + "\""); } writeOut(outputstream, " ?>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); // Print the DOCTYPE DECL only if right info exists if (XMLDeclAttribs.containsKey("rootName") && XMLDeclAttribs.containsKey("dtdName")) { // print the DOCTYPE DECL IF its a structure node if(classXDFNodeName != null && classXDFNodeName.equals(sXDFStructureNodeName) ) { writeOut(outputstream, "<!DOCTYPE " + XMLDeclAttribs.get("rootName") + " SYSTEM \"" + XMLDeclAttribs.get("dtdName") + "\">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } else Log.errorln("Passed XMLDeclAttributes table lacks either dtdName, rootName entries, ignoring DOCTYPE line printout"); } |
if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } else Log.errorln("Passed XMLDeclAttributes table lacks either dtdName, rootName entries, ignoring DOCTYPE line printout"); | if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); } else Log.errorln("Passed XMLDeclAttributes table lacks either dtdName, rootName entries, ignoring DOCTYPE line printout"); | private void writeXMLDeclToOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs ) { // initial statement writeOut(outputstream, "<?xml"); writeOut(outputstream, " version=\"" + sXMLSpecVersion + "\""); // print attributes Enumeration keys = XMLDeclAttribs.keys(); while ( keys.hasMoreElements() ) { String attribName = (String) keys.nextElement(); if (attribName.equals("version") ) { Log.errorln("XMLDeclAttrib hash has version attribute, not allowed and ignoring."); } else if ( attribName.equals("dtdName") || attribName.equals("rootName") ) { // skip over it } else writeOut(outputstream, " " + attribName + "=\"" + XMLDeclAttribs.get(attribName) + "\""); } writeOut(outputstream, " ?>"); if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); // Print the DOCTYPE DECL only if right info exists if (XMLDeclAttribs.containsKey("rootName") && XMLDeclAttribs.containsKey("dtdName")) { // print the DOCTYPE DECL IF its a structure node if(classXDFNodeName != null && classXDFNodeName.equals(sXDFStructureNodeName) ) { writeOut(outputstream, "<!DOCTYPE " + XMLDeclAttribs.get("rootName") + " SYSTEM \"" + XMLDeclAttribs.get("dtdName") + "\">"); } if (sPrettyXDFOutput) writeOut(outputstream, Constants.NEW_LINE); } else Log.errorln("Passed XMLDeclAttributes table lacks either dtdName, rootName entries, ignoring DOCTYPE line printout"); } |
frame = new Gui5250Frame(this); | My5250 () { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { } frame = new Gui5250Frame(this); loadSessions(); int width = 600; int height = 500; if (sessions.containsKey("emul.width")) width = Integer.parseInt(sessions.getProperty("emul.width")); if (sessions.containsKey("emul.height")) height = Integer.parseInt(sessions.getProperty("emul.height")); frame.setSize(width,height); centerFrame(); frame.sessionPane.addChangeListener(this); focused = createImageIcon("focused.gif"); unfocused = createImageIcon("unfocused.gif"); ImageIcon tnicon = createImageIcon("tnicon.jpg"); frame.setIconImage(tnicon.getImage()); sessionsV = new Vector(); setDefaultLocale(); manager = new SessionManager(); manager.setController(this); } |
|
int width = 600; int height = 500; if (sessions.containsKey("emul.width")) width = Integer.parseInt(sessions.getProperty("emul.width")); if (sessions.containsKey("emul.height")) height = Integer.parseInt(sessions.getProperty("emul.height")); frame.setSize(width,height); centerFrame(); frame.sessionPane.addChangeListener(this); | My5250 () { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { } frame = new Gui5250Frame(this); loadSessions(); int width = 600; int height = 500; if (sessions.containsKey("emul.width")) width = Integer.parseInt(sessions.getProperty("emul.width")); if (sessions.containsKey("emul.height")) height = Integer.parseInt(sessions.getProperty("emul.height")); frame.setSize(width,height); centerFrame(); frame.sessionPane.addChangeListener(this); focused = createImageIcon("focused.gif"); unfocused = createImageIcon("unfocused.gif"); ImageIcon tnicon = createImageIcon("tnicon.jpg"); frame.setIconImage(tnicon.getImage()); sessionsV = new Vector(); setDefaultLocale(); manager = new SessionManager(); manager.setController(this); } |
|
ImageIcon tnicon = createImageIcon("tnicon.jpg"); frame.setIconImage(tnicon.getImage()); sessionsV = new Vector(); | tnicon = createImageIcon("tnicon.jpg"); frames = new Vector(); newView(); | My5250 () { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { } frame = new Gui5250Frame(this); loadSessions(); int width = 600; int height = 500; if (sessions.containsKey("emul.width")) width = Integer.parseInt(sessions.getProperty("emul.width")); if (sessions.containsKey("emul.height")) height = Integer.parseInt(sessions.getProperty("emul.height")); frame.setSize(width,height); centerFrame(); frame.sessionPane.addChangeListener(this); focused = createImageIcon("focused.gif"); unfocused = createImageIcon("unfocused.gif"); ImageIcon tnicon = createImageIcon("tnicon.jpg"); frame.setIconImage(tnicon.getImage()); sessionsV = new Vector(); setDefaultLocale(); manager = new SessionManager(); manager.setController(this); } |
out.flush(); out.close(); boot.close(); | static private boolean checkBootStrapper (String[] args) { try { Socket boot = new Socket("localhost", 3036); PrintWriter out = new PrintWriter(boot.getOutputStream(), true); // parse args into a string to send to the other instance of // tn5250j String opts = null; for (int x = 0;x < args.length; x++) { if (opts != null) opts += args[x] + " "; else opts = args[x] + " "; } out.println(opts); return true; } catch (UnknownHostException e) { System.err.println("localhost not known."); } catch (IOException e) { System.err.println("No other instances of tn5250j running."); } return false; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.