bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.borderSpacing.top += m.textAscent; } return m; }
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.innerSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.borderSpacing.top += m.textAscent; } return m; }
13,047
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.borderSpacing.top += m.textAscent; } return m; }
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.innerSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.borderSpacing.top += m.textAscent; } return m; }
13,048
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.borderSpacing.top += m.textAscent; } return m; }
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.borderSpacing.top += m.textAscent; } return m; }
13,049
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.borderSpacing.top += m.textAscent; } return m; }
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.outerSpacing.bottom += m.textAscent + m.textDescent; break; default: m.borderSpacing.top += m.textAscent; } return m; }
13,050
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.borderSpacing.top += m.textAscent; } return m; }
private Measurements getMeasurements(Component c) { Measurements m = new Measurements(); FontMetrics fmet; m.font = getFont(c); fmet = c.getFontMetrics(m.font); m.border = getBorder(); if (m.border != null) m.borderInsets = m.border.getBorderInsets(c); else m.borderInsets = new Insets(0, 0, 0, 0); if (title != null) { m.trimmedText = title.trim(); if (m.trimmedText.length() == 0) m.trimmedText = null; } m.textAscent = fmet.getAscent(); m.textDescent = fmet.getDescent(); FontRenderContext frc = new FontRenderContext(new AffineTransform(), false, false); LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0, m.trimmedText.length(), frc); m.lineHeight = (int) lmet.getStrikethroughOffset(); // Fallback in case that LineMetrics is not available/working. if (m.lineHeight == 0) m.lineHeight = (int) (0.3333 * (double) m.textAscent); if (m.trimmedText != null) m.textWidth = fmet.stringWidth(m.trimmedText) + 3; m.edgeSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, EDGE_SPACING); m.borderSpacing = new Insets(0, 0, 0, 0); switch (titlePosition) { case ABOVE_TOP: m.borderSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case BELOW_TOP: m.edgeSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING; break; case ABOVE_BOTTOM: m.edgeSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; case BOTTOM: m.edgeSpacing.bottom += Math.max(m.textAscent - m.borderInsets.bottom, 0); m.borderSpacing.bottom += m.textDescent; break; case BELOW_BOTTOM: m.borderSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING; break; default: m.outerSpacing.top += m.textAscent; } return m; }
13,051
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width, height); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,052
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, x + width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,053
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,054
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.outerSpacing.left, y + mes.outerSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,055
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + EDGE_SPACING + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,056
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y + EDGE_SPACING; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,057
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.outerSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,058
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.outerSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,059
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.outerSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,060
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Measurements mes = getMeasurements(c); Font oldFont = g.getFont(); Color oldColor = g.getColor(); /** * A local helper class for painting the border without changing * any pixels inside the rectangle of the title text. */ class BorderPainter { private Component c; private Border b; private int x, y, width, height; /** * Constructs a BorderPainter. * * @param c the component whose border is being painted. * @param b the border object. * @param x the x coordinate of the rectangle delimiting the border. * @param y the y coordinate of the rectangle delimiting the border. * @param width the width of the rectangle delimiting the border. * @param height the width of the rectangle delimiting the border. */ public BorderPainter(Component c, Border b, int x, int y, int width, int height) { this.c = c; this.b = b; this.x = x; this.y = y; this.width = width; this.height = height; } /** * Paints the entire border. */ public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); } /** * Paints the border, clipping the drawing operation to a * given rectangular area. */ private void paint(Graphics g, int clipX, int clipY, int clipWidth, int clipHeight) { Shape oldClip = g.getClip(); try { g.clipRect(clipX, clipY, clipWidth, clipHeight); paint(g); } finally { g.setClip(oldClip); } } /** * Paints the border without affecting a given rectangular area. * This is used for painting the border without drawing anything * underneath the title text. * * <p>Since we do not want to introduce unnecessary dependencies * on Java 2D, we perform the clipping without constructive geometry * (provided by java.awt.geom.Area). Instead, the border&#x2019;s * bounding rectangle is split into smaller parts, which are then * clipped and painted individually.: * * <p><pre> * +--------------------+ +--------------------+ * | | | 1 | * | +--------+ | +---+--------+-------+ * | | hole | | |====> | 2 | hole | 3 | * | +--------+ | |---+--------+-------+ * | | | 4 | * +--------------------+ +--------------------+</pre> * */ public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 } }; BorderPainter bp; int textX, textY, borderWidth, borderHeight; borderWidth = width - (mes.borderSpacing.left + mes.borderSpacing.right); borderHeight = height - (mes.borderSpacing.top + mes.borderSpacing.bottom); bp = new BorderPainter(c, getBorder(), x + mes.borderSpacing.left, y + mes.borderSpacing.top, borderWidth, borderHeight); switch (getRealTitleJustification(c)) { case LEFT: textX = x + TEXT_INSET_H; break; case CENTER: textX = x + (borderWidth - mes.textWidth) / 2; break; case RIGHT: textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H); break; default: throw new IllegalStateException(); } switch (titlePosition) { case ABOVE_TOP: textY = y; break; case TOP: case DEFAULT_POSITION: default: textY = y + mes.borderSpacing.top + mes.borderInsets.top - mes.textAscent + mes.lineHeight; break; case BELOW_TOP: textY = y + mes.borderSpacing.top + mes.borderInsets.top + TEXT_SPACING; break; case ABOVE_BOTTOM: textY = y + height - mes.borderSpacing.bottom - mes.borderInsets.bottom - TEXT_SPACING - (mes.textAscent + mes.textDescent); break; case BOTTOM: case BELOW_BOTTOM: textY = y + height - (mes.textAscent + mes.textDescent); break; } if (mes.trimmedText == null) bp.paint(g); else { try { g.setFont(mes.font); g.setColor(getTitleColor()); g.drawString(mes.trimmedText, textX, textY + mes.textAscent); } finally { g.setFont(oldFont); g.setColor(oldColor); } bp.paintExcept(g, textX - 2, textY, mes.textWidth + 2, mes.textAscent + mes.textDescent); } }
13,061
public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width - 1, height - 1); }
public void paint(Graphics g) { if (b != null) b.paintBorder(c, g, x, y, width, height); }
13,062
public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 }
public void paintExcept(Graphics g, int holeX, int holeY, int holeWidth, int holeHeight) { int stripeHeight; stripeHeight = holeY - y; if (stripeHeight > 0) paint(g, x, y, width, stripeHeight); // patch #1 in the image above stripeHeight = holeHeight; if (stripeHeight > 0) { paint(g, x, holeY, holeX - x, stripeHeight); // patches #2 and #3 paint(g, holeX + holeWidth, holeY, x + width - (holeX + holeWidth), stripeHeight); } stripeHeight = height - (holeY - y + holeHeight); if (stripeHeight > 0) paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4 }
13,063
private String validateClassName(String cn) throws IOException { if (cn.startsWith(".") || cn.endsWith(".")) abort("MODULE_CLASS MUST NOT start or end with a '.'"); String[] tokens = cn.split("."); for (int i = 0; i < tokens.length; i++) { String t = tokens[i]; if (Character.isJavaIdentifierStart(cn.toCharArray()[0])) abort(""); // we dont check the rest of the characters for isJavaIdentifierPart() // because that's what the tokenizer does. } return cn; }
private String validateClassName(String cn) throws IOException { if (cn.startsWith(".") || cn.endsWith(".")) abort("MODULE_CLASS MUST NOT start or end with a '.'"); String[] tokens = cn.split("\\."); for (int i = 0; i < tokens.length; i++) { String t = tokens[i]; if (Character.isJavaIdentifierStart(cn.toCharArray()[0])) abort(""); // we dont check the rest of the characters for isJavaIdentifierPart() // because that's what the tokenizer does. } return cn; }
13,064
private String validateClassName(String cn) throws IOException { if (cn.startsWith(".") || cn.endsWith(".")) abort("MODULE_CLASS MUST NOT start or end with a '.'"); String[] tokens = cn.split("."); for (int i = 0; i < tokens.length; i++) { String t = tokens[i]; if (Character.isJavaIdentifierStart(cn.toCharArray()[0])) abort(""); // we dont check the rest of the characters for isJavaIdentifierPart() // because that's what the tokenizer does. } return cn; }
private String validateClassName(String cn) throws IOException { if (cn.startsWith(".") || cn.endsWith(".")) abort("MODULE_CLASS MUST NOT start or end with a '.'"); String[] tokens = cn.split("."); for (int i = 0; i < tokens.length; i++) { String t = tokens[i]; if (Character.isJavaIdentifierStart(cn.toCharArray()[0])) abort(""); // we dont check the rest of the characters for isJavaIdentifierPart() // because that's what the tokenizer does. } return cn; }
13,065
public abstract void put (String name, Object value);
public abstract void put (String name, boolean value);
13,066
public void useProtocolVersion(int version) throws IOException { if (version != PROTOCOL_VERSION_1 && version != PROTOCOL_VERSION_2) throw new IOException("Invalid protocol version requested."); protocolVersion = version; }
public void useProtocolVersion(int version) throws IOException { if (version != PROTOCOL_VERSION_1 && version != PROTOCOL_VERSION_2) throw new IllegalArgumentException("Invalid protocol version requested."); protocolVersion = version; }
13,067
protected void installDefaults(JScrollPane p) { scrollpane = p; UIDefaults defaults = UIManager.getLookAndFeelDefaults(); p.setForeground(defaults.getColor("ScrollPane.foreground")); p.setBackground(defaults.getColor("ScrollPane.background")); p.setFont(defaults.getFont("ScrollPane.font")); p.setBorder(defaults.getBorder("ScrollPane.border")); p.setOpaque(true); }
protected void installDefaults(JScrollPane p) { scrollpane = p; UIDefaults defaults = UIManager.getLookAndFeelDefaults(); p.setForeground(defaults.getColor("ScrollPane.foreground")); p.setBackground(defaults.getColor("ScrollPane.background")); p.setFont(defaults.getFont("ScrollPane.font")); p.setBorder(defaults.getBorder("ScrollPane.border")); p.setOpaque(true); }
13,070
public void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); popupMenu.setBackground(defaults.getColor("PopupMenu.background")); popupMenu.setBorder(defaults.getBorder("PopupMenu.border")); popupMenu.setFont(defaults.getFont("PopupMenu.font")); popupMenu.setForeground(defaults.getColor("PopupMenu.foreground")); popupMenu.setOpaque(true); }
public void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); popupMenu.setBackground(defaults.getColor("PopupMenu.background")); popupMenu.setBorder(defaults.getBorder("PopupMenu.border")); popupMenu.setFont(defaults.getFont("PopupMenu.font")); popupMenu.setForeground(defaults.getColor("PopupMenu.foreground")); popupMenu.setOpaque(true); }
13,071
public final Object getContent() throws IOException { return openConnection().getContent(); }
public Object getContent() throws IOException { return openConnection().getContent(); }
13,072
public int getDefaultPort() { return handler.getDefaultPort(); }
public int getDefaultPort() { return handler.getDefaultPort(); }
13,073
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
13,074
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
13,075
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
13,076
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
13,077
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
13,078
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
13,079
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
13,080
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad return null; }
private static synchronized URLStreamHandler getURLStreamHandler( String protocol) { // First, see if a protocol handler is in our cache if (cache_handlers) { final Class cls = (Class) ph_cache.get(protocol); if (cls != null) { try { return (URLStreamHandler) cls.newInstance(); } catch (Exception e) { // Do nothing } } } // Next check the factory and use that if set if (factory != null) { URLStreamHandler ph; ph = factory.createURLStreamHandler(protocol); if (ph != null) { if (cache_handlers) { ph_cache.put(protocol, ph.getClass()); } return (ph); } } // Finally loop through our search path looking for a match StringTokenizer st = new StringTokenizer(ph_search_path, "|"); while (st.hasMoreTokens()) { String clsname = st.nextToken() + "." + protocol + ".Handler"; try { final ClassLoader cl = Thread.currentThread() .getContextClassLoader(); final Class cls = cl.loadClass(clsname); Object obj = cls.newInstance(); URLStreamHandler ph; if (!(obj instanceof URLStreamHandler)) { continue; } else { ph = (URLStreamHandler) obj; } if (cache_handlers) { ph_cache.put(protocol, cls); } return (ph); } catch (Exception e) { // Do nothing } } // Still here, which is bad do { try { String clsName = (pkgPrefix.nextToken() + "." + protocol + ".Handler"); Class c = Class.forName(clsName, true, systemClassLoader); ph = (URLStreamHandler) c.newInstance(); } catch (ThreadDeath death) { throw death; } catch (Throwable t) { } } while (ph == null && pkgPrefix.hasMoreTokens()); } if (ph != null && cache_handlers) ph_cache.put(protocol, ph); else ph = null; return ph; }
13,081
public String getUserInfo() { int at = (host == null) ? -1 : host.indexOf('@'); return at < 0 ? null : host.substring(0, at); }
public String getUserInfo() { if (userInfo != null) return userInfo; int at = (host == null) ? -1 : host.indexOf('@'); return at < 0 ? null : host.substring(0, at); }
13,082
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); this.handler = getURLStreamHandler(protocol); if (this.handler == null) throw new IOException("Handler for protocol " + protocol + " not found"); }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); this.handler = getURLStreamHandler(protocol); if (this.handler == null) throw new IOException("Handler for protocol " + protocol + " not found"); }
13,083
public boolean sameFile(URL other) { return handler.sameFile(this, other); }
public boolean sameFile(URL other) { return handler.sameFile(this, other); }
13,084
protected void set(String protocol, String host, int port, String file, String ref) { // TBD: Theoretically, a poorly written StreamHandler could pass an // invalid protocol. It will cause the handler to be set to null // thus overriding a valid handler. Callers of this method should // be aware of this. this.handler = getURLStreamHandler(protocol); this.protocol = protocol.toLowerCase(); this.authority = null; this.port = port; this.host = host; this.file = file; this.ref = ref; hashCode = hashCode(); // Used for serialization. }
protected void set(String protocol, String host, int port, String file, String ref) { // TBD: Theoretically, a poorly written StreamHandler could pass an // invalid protocol. It will cause the handler to be set to null // thus overriding a valid handler. Callers of this method should // be aware of this. this.handler = getURLStreamHandler(protocol); this.protocol = protocol.toLowerCase(); this.authority = null; this.port = port; this.host = host; this.file = file; this.ref = ref; hashCode = hashCode(); // Used for serialization. }
13,085
public static synchronized void setURLStreamHandlerFactory( URLStreamHandlerFactory fac) { if ((factory != null) && (fac != null)) { throw new Error("URLStreamHandlerFactory already set"); } // Throw an exception if an extant security mgr precludes // setting the factory. SecurityManager s = System.getSecurityManager(); if (s != null) { s.checkSetFactory(); } factory = fac; }
public static synchronized void setURLStreamHandlerFactory( URLStreamHandlerFactory fac) { if ((factory != null) && (fac != null)) { throw new Error("URLStreamHandlerFactory already set"); } // Throw an exception if an extant security mgr precludes // setting the factory. SecurityManager s = System.getSecurityManager(); if (s != null) { s.checkSetFactory(); } factory = fac; }
13,087
public static synchronized void setURLStreamHandlerFactory( URLStreamHandlerFactory fac) { if ((factory != null) && (fac != null)) { throw new Error("URLStreamHandlerFactory already set"); } // Throw an exception if an extant security mgr precludes // setting the factory. SecurityManager s = System.getSecurityManager(); if (s != null) { s.checkSetFactory(); } factory = fac; }
public static synchronized void setURLStreamHandlerFactory( URLStreamHandlerFactory fac) { if ((factory != null) && (fac != null)) { throw new Error("URLStreamHandlerFactory already set"); // Throw an exception if an extant security mgr precludes // setting the factory. SecurityManager s = System.getSecurityManager(); if (s != null) { s.checkSetFactory(); factory = fac;
13,088
public static synchronized void setURLStreamHandlerFactory( URLStreamHandlerFactory fac) { if ((factory != null) && (fac != null)) { throw new Error("URLStreamHandlerFactory already set"); } // Throw an exception if an extant security mgr precludes // setting the factory. SecurityManager s = System.getSecurityManager(); if (s != null) { s.checkSetFactory(); } factory = fac; }
public static synchronized void setURLStreamHandlerFactory( URLStreamHandlerFactory fac) { if ((factory != null) && (fac != null)) { throw new Error("URLStreamHandlerFactory already set"); } // Throw an exception if an extant security mgr precludes // setting the factory. SecurityManager s = System.getSecurityManager(); if (s != null) s.checkSetFactory(); } factory = fac; }
13,089
public int read(ByteBuffer dst) throws IOException { if (!isConnected()) throw new NotYetConnectedException(); byte[] data; int offset = 0; InputStream input = socket.getInputStream(); int available = input.available(); int len = dst.capacity() - dst.position(); if ((! isBlocking()) && available == 0) return 0; if (dst.hasArray()) { offset = dst.arrayOffset() + dst.position(); data = dst.array(); } else { data = new byte [len]; } int readBytes = 0; boolean completed = false; try { begin(); socket.getPlainSocketImpl().setInChannelOperation(true); readBytes = input.read (data, offset, len); completed = true; } finally { end (completed); socket.getPlainSocketImpl().setInChannelOperation(false); } if (readBytes > 0) if (dst.hasArray()) { dst.position (dst.position() + readBytes); } else { dst.put (data, offset, len); } return readBytes; }
public int read(ByteBuffer dst) throws IOException { if (!isConnected()) throw new NotYetConnectedException(); byte[] data; int offset = 0; InputStream input = socket.getInputStream(); int available = input.available(); int len = dst.capacity() - dst.position(); if ((! isBlocking()) && available == 0) return 0; if (dst.hasArray()) { offset = dst.arrayOffset() + dst.position(); data = dst.array(); } else { data = new byte [len]; } int readBytes = 0; boolean completed = false; try { begin(); socket.getPlainSocketImpl().setInChannelOperation(true); readBytes = input.read (data, offset, len); completed = true; } finally { end (completed); socket.getPlainSocketImpl().setInChannelOperation(false); } if (readBytes > 0) if (dst.hasArray()) { dst.position (dst.position() + readBytes); } else { dst.put (data, offset, readBytes); } return readBytes; }
13,090
Attribute(String name, String type, boolean specified, String value) { this.name = name; this.type = type; this.specified = specified; this.value = value; int ci = name.indexOf(':'); if (ci == -1) { prefix = null; localName = name; } else { prefix = intern(name.substring(0, ci)); localName = intern(name.substring(ci + 1)); } }
Attribute(String name, String type, boolean specified, String value) { this.name = name; this.type = type; this.specified = specified; this.value = value; int ci = name.indexOf(':'); if (ci == -1) { prefix = null; localName = intern(name); } else { prefix = intern(name.substring(0, ci)); localName = intern(name.substring(ci + 1)); } }
13,091
public boolean equals(Object other) { if (other instanceof Attribute) { return ((Attribute) other).name.equals(name); } return false; }
public boolean equals(Object other) { if (other instanceof Attribute) { Attribute a = (Attribute) other; if (namespaceAware) { if (!a.localName.equals(localName)) return false; String auri = getNamespaceURI(a.prefix); String uri = getNamespaceURI(prefix); if (uri == null && (auri == null || (input.xml11 && "".equals(auri)))) return true; if (uri != null) { if ("".equals(uri) && input.xml11 && "".equals(auri)) return true; return uri.equals(auri); } return false; } else return a.name.equals(name); } return false; }
13,092
AttributeDecl(String type, String value, int valueType, String enumeration) { this.type = type; this.value = value; this.valueType = valueType; this.enumeration = enumeration; }
AttributeDecl(String type, String value, int valueType, String enumeration, HashSet values, boolean external) { this.type = type; this.value = value; this.valueType = valueType; this.enumeration = enumeration; }
13,093
void addElementDecl(String name, String model) { if (elements.containsKey(name)) return; elements.put(name, model); entries.add("E" + name); }
void addElementDecl(String name, String text, ContentModel model) { if (elements.containsKey(name)) return; elements.put(name, model); entries.add("E" + name); }
13,095
Input(InputStream in, String publicId, String systemId, String name) { this(in, null, publicId, systemId, name, null); }
Input(InputStream in, Reader reader, String publicId, String systemId, String name, String inputEncoding, boolean report, boolean normalize) { this(in, null, publicId, systemId, name, null); }
13,097
Input(InputStream in, String publicId, String systemId, String name) { this(in, null, publicId, systemId, name, null); }
Input(InputStream in, String publicId, String systemId, String name) { if (inputEncoding == null) inputEncoding = "UTF-8"; this.inputEncoding = inputEncoding; this.publicId = publicId; this.systemId = systemId; this.name = name; this.report = report; this.normalize = normalize; if (in != null) { if (reader != null) throw new IllegalStateException("both byte and char streams "+ "specified"); if (normalize) in = new CRLFInputStream(in); in = new BufferedInputStream(in); this.in = in; } else { this.reader = normalize ? new CRLFReader(reader) : reader; unicodeReader = new UnicodeReader(this.reader); } initialized = false; }
13,098
private void detectEncoding() throws IOException { int[] signature = new int[4]; in.mark(4); for (int i = 0; i < 4; i++) signature[i] = in.read(); in.reset(); // 4-byte encodings if (equals(SIGNATURE_UCS_4_1234, signature)) setInputEncoding("UTF-32BE"); else if (equals(SIGNATURE_UCS_4_4321, signature)) setInputEncoding("UTF-32LE"); else if (equals(SIGNATURE_UCS_4_2143, signature) || equals(SIGNATURE_UCS_4_3412, signature)) throw new UnsupportedEncodingException("unsupported UCS-4 byte ordering"); // 2-byte encodings else if (equals(SIGNATURE_UCS_2_12, signature)) { setInputEncoding("UTF-16BE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_21, signature)) { setInputEncoding("UTF-16LE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_12_NOBOM, signature)) { setInputEncoding("UTF-16BE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } else if (equals(SIGNATURE_UCS_2_21_NOBOM, signature)) { setInputEncoding("UTF-16LE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } // ASCII-derived encodings else if (equals(SIGNATURE_UTF_8, signature)) { // UTF-8 input encoding implied, TextDecl } else if (equals(SIGNATURE_UTF_8_BOM, signature)) { setInputEncoding("UTF-8"); in.read(); in.read(); in.read(); } }
private void detectEncoding() throws IOException { int[] signature = new int[4]; in.mark(4); for (int i = 0; i < 4; i++) signature[i] = in.read(); in.reset(); // 4-byte encodings if (equals(SIGNATURE_UCS_4_1234, signature)) setInputEncoding("UTF-32BE"); else if (equals(SIGNATURE_UCS_4_4321, signature)) setInputEncoding("UTF-32LE"); else if (equals(SIGNATURE_UCS_4_2143, signature) || equals(SIGNATURE_UCS_4_3412, signature)) throw new UnsupportedEncodingException("unsupported UCS-4 byte ordering"); // 2-byte encodings else if (equals(SIGNATURE_UCS_2_12, signature)) { in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_21, signature)) { setInputEncoding("UTF-16LE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_12_NOBOM, signature)) { throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } else if (equals(SIGNATURE_UCS_2_21_NOBOM, signature)) { setInputEncoding("UTF-16LE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } // ASCII-derived encodings else if (equals(SIGNATURE_UTF_8, signature)) { // UTF-8 input encoding implied, TextDecl } else if (equals(SIGNATURE_UTF_8_BOM, signature)) { setInputEncoding("UTF-8"); in.read(); in.read(); in.read(); } }
13,099
private void detectEncoding() throws IOException { int[] signature = new int[4]; in.mark(4); for (int i = 0; i < 4; i++) signature[i] = in.read(); in.reset(); // 4-byte encodings if (equals(SIGNATURE_UCS_4_1234, signature)) setInputEncoding("UTF-32BE"); else if (equals(SIGNATURE_UCS_4_4321, signature)) setInputEncoding("UTF-32LE"); else if (equals(SIGNATURE_UCS_4_2143, signature) || equals(SIGNATURE_UCS_4_3412, signature)) throw new UnsupportedEncodingException("unsupported UCS-4 byte ordering"); // 2-byte encodings else if (equals(SIGNATURE_UCS_2_12, signature)) { setInputEncoding("UTF-16BE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_21, signature)) { setInputEncoding("UTF-16LE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_12_NOBOM, signature)) { setInputEncoding("UTF-16BE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } else if (equals(SIGNATURE_UCS_2_21_NOBOM, signature)) { setInputEncoding("UTF-16LE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } // ASCII-derived encodings else if (equals(SIGNATURE_UTF_8, signature)) { // UTF-8 input encoding implied, TextDecl } else if (equals(SIGNATURE_UTF_8_BOM, signature)) { setInputEncoding("UTF-8"); in.read(); in.read(); in.read(); } }
private void detectEncoding() throws IOException { int[] signature = new int[4]; in.mark(4); for (int i = 0; i < 4; i++) signature[i] = in.read(); in.reset(); // 4-byte encodings if (equals(SIGNATURE_UCS_4_1234, signature)) setInputEncoding("UTF-32BE"); else if (equals(SIGNATURE_UCS_4_4321, signature)) setInputEncoding("UTF-32LE"); else if (equals(SIGNATURE_UCS_4_2143, signature) || equals(SIGNATURE_UCS_4_3412, signature)) throw new UnsupportedEncodingException("unsupported UCS-4 byte ordering"); // 2-byte encodings else if (equals(SIGNATURE_UCS_2_12, signature)) { setInputEncoding("UTF-16BE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_21, signature)) { in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_12_NOBOM, signature)) { setInputEncoding("UTF-16BE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } else if (equals(SIGNATURE_UCS_2_21_NOBOM, signature)) { throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } // ASCII-derived encodings else if (equals(SIGNATURE_UTF_8, signature)) { // UTF-8 input encoding implied, TextDecl } else if (equals(SIGNATURE_UTF_8_BOM, signature)) { setInputEncoding("UTF-8"); in.read(); in.read(); in.read(); } }
13,100
private void detectEncoding() throws IOException { int[] signature = new int[4]; in.mark(4); for (int i = 0; i < 4; i++) signature[i] = in.read(); in.reset(); // 4-byte encodings if (equals(SIGNATURE_UCS_4_1234, signature)) setInputEncoding("UTF-32BE"); else if (equals(SIGNATURE_UCS_4_4321, signature)) setInputEncoding("UTF-32LE"); else if (equals(SIGNATURE_UCS_4_2143, signature) || equals(SIGNATURE_UCS_4_3412, signature)) throw new UnsupportedEncodingException("unsupported UCS-4 byte ordering"); // 2-byte encodings else if (equals(SIGNATURE_UCS_2_12, signature)) { setInputEncoding("UTF-16BE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_21, signature)) { setInputEncoding("UTF-16LE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_12_NOBOM, signature)) { setInputEncoding("UTF-16BE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } else if (equals(SIGNATURE_UCS_2_21_NOBOM, signature)) { setInputEncoding("UTF-16LE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } // ASCII-derived encodings else if (equals(SIGNATURE_UTF_8, signature)) { // UTF-8 input encoding implied, TextDecl } else if (equals(SIGNATURE_UTF_8_BOM, signature)) { setInputEncoding("UTF-8"); in.read(); in.read(); in.read(); } }
private void detectEncoding() throws IOException { int[] signature = new int[4]; in.mark(4); for (int i = 0; i < 4; i++) signature[i] = in.read(); in.reset(); // 4-byte encodings if (equals(SIGNATURE_UCS_4_1234, signature)) setInputEncoding("UTF-32BE"); else if (equals(SIGNATURE_UCS_4_4321, signature)) setInputEncoding("UTF-32LE"); else if (equals(SIGNATURE_UCS_4_2143, signature) || equals(SIGNATURE_UCS_4_3412, signature)) throw new UnsupportedEncodingException("unsupported UCS-4 byte ordering"); // 2-byte encodings else if (equals(SIGNATURE_UCS_2_12, signature)) { setInputEncoding("UTF-16BE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_21, signature)) { setInputEncoding("UTF-16LE"); in.read(); in.read(); } else if (equals(SIGNATURE_UCS_2_12_NOBOM, signature)) { setInputEncoding("UTF-16BE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } else if (equals(SIGNATURE_UCS_2_21_NOBOM, signature)) { setInputEncoding("UTF-16LE"); throw new UnsupportedEncodingException("no byte-order mark for UCS-2 entity"); } // ASCII-derived encodings else if (equals(SIGNATURE_UTF_8, signature)) { // UTF-8 input encoding implied, TextDecl } else if (equals(SIGNATURE_UTF_8_BOM, signature)) { in.read(); in.read(); in.read(); } }
13,101
void init() throws IOException { if (initialized) return; if (!forceReader && in != null) detectEncoding(); initialized = true; }
void init() throws IOException { if (initialized) return; if (in != null) detectEncoding(); initialized = true; }
13,103
void mark(int len) throws IOException { //System.out.println(" mark:"+len); markOffset = offset; markLine = line; markColumn = column; reader.mark(len); }
void mark(int len) throws IOException { //System.out.println(" mark:"+len); markOffset = offset; markLine = line; markColumn = column; if (unicodeReader != null) unicodeReader.mark(len); else in.mark(len); }
13,104
int read() throws IOException { offset++; int ret = reader.read(); //System.out.println("read1:"+((char) ret)); if (ret == 0x0d) ret = 0x0a; if (ret == 0x0a) { line++; column = 0; } else column++; return ret; }
int read() throws IOException { offset++; int ret = reader.read(); //System.out.println("read1:"+((char) ret)); if (ret == 0x0d) ret = 0x0a; if (ret == 0x0a) { line++; column = 0; } else column++; return ret; }
13,105
void reset() throws IOException { //System.out.println(" reset"); reader.reset(); offset = markOffset; line = markLine; column = markColumn; }
void reset() throws IOException { //System.out.println(" reset"); if (unicodeReader != null) unicodeReader.reset(); else in.reset(); offset = markOffset; line = markLine; column = markColumn; }
13,107
private void setInputEncoding(String encoding) throws UnsupportedEncodingException { if (!encoding.equals(inputEncoding) && reader instanceof XMLInputStreamReader) { inputEncoding = encoding; reader = new XMLInputStreamReader((XMLInputStreamReader) reader, encoding); } else { /*if (reporter != null) { try { reporter.report("unable to set input encoding '" + encoding + "': input is specified as reader", "WARNING", encoding, this); } catch (XMLStreamException e) { // Am I bothered? }}*/ System.err.println("Can't set input encoding "+encoding); } }
private void setInputEncoding(String encoding) throws UnsupportedEncodingException { if (!encoding.equals(inputEncoding) && reader instanceof XMLInputStreamReader) { inputEncoding = encoding; reader = new XMLInputStreamReader((XMLInputStreamReader) reader, encoding); } else { /*if (reporter != null) { try { reporter.report("unable to set input encoding '" + encoding + "': input is specified as reader", "WARNING", encoding, this); } catch (XMLStreamException e) { // Am I bothered? }}*/ System.err.println("Can't set input encoding "+encoding); } }
13,108
private void setInputEncoding(String encoding) throws UnsupportedEncodingException { if (!encoding.equals(inputEncoding) && reader instanceof XMLInputStreamReader) { inputEncoding = encoding; reader = new XMLInputStreamReader((XMLInputStreamReader) reader, encoding); } else { /*if (reporter != null) { try { reporter.report("unable to set input encoding '" + encoding + "': input is specified as reader", "WARNING", encoding, this); } catch (XMLStreamException e) { // Am I bothered? }}*/ System.err.println("Can't set input encoding "+encoding); } }
private void setInputEncoding(String encoding) throws UnsupportedEncodingException { if (!encoding.equals(inputEncoding) && reader instanceof XMLInputStreamReader) { inputEncoding = encoding; reader = new XMLInputStreamReader((XMLInputStreamReader) reader, encoding); } else { /*if (reporter != null) { try { reporter.report("unable to set input encoding '" + encoding + "': input is specified as reader", "WARNING", encoding, this); } catch (XMLStreamException e) { // Am I bothered? }}*/ System.err.println("Can't set input encoding "+encoding); } }
13,109
private void setInputEncoding(String encoding) throws UnsupportedEncodingException { if (!encoding.equals(inputEncoding) && reader instanceof XMLInputStreamReader) { inputEncoding = encoding; reader = new XMLInputStreamReader((XMLInputStreamReader) reader, encoding); } else { /*if (reporter != null) { try { reporter.report("unable to set input encoding '" + encoding + "': input is specified as reader", "WARNING", encoding, this); } catch (XMLStreamException e) { // Am I bothered? }}*/ System.err.println("Can't set input encoding "+encoding); } }
private void setInputEncoding(String encoding) throws UnsupportedEncodingException { if (!encoding.equals(inputEncoding) && reader instanceof XMLInputStreamReader) { inputEncoding = encoding; reader = new XMLInputStreamReader((XMLInputStreamReader) reader, encoding); } else { /*if (reporter != null) { try { reporter.report("unable to set input encoding '" + encoding + "': input is specified as reader", "WARNING", encoding, this); } catch (XMLStreamException e) { // Am I bothered? }}*/ System.err.println("Can't set input encoding "+encoding); } }
13,110
private void expandEntity(String name, boolean inAttr) throws IOException, XMLStreamException { if (doctype != null) { Object value = doctype.getEntity(name); if (value != null) { if (xmlStandalone == Boolean.TRUE) { if (doctype.isEntityExternal(name)) error("reference to external entity in standalone document"); else if (value instanceof ExternalIds) { ExternalIds ids = (ExternalIds) value; if (ids.notationName != null && doctype.isNotationExternal(ids.notationName)) error("reference to external notation in " + "standalone document"); } } if (value instanceof String) { String text = (String) value; if (inAttr && text.indexOf('<') != -1) error("< in attribute value"); pushInput(name, text); } else if (inAttr) error("reference to external entity in attribute value", name); else pushInput(name, (ExternalIds) value); if (name != null) startEntityStack.addFirst(name); return; } } error("reference to undeclared entity", name); }
private void expandEntity(String name, boolean inAttr, boolean normalize) throws IOException, XMLStreamException { if (doctype != null) { Object value = doctype.getEntity(name); if (value != null) { if (xmlStandalone == Boolean.TRUE) { if (doctype.isEntityExternal(name)) error("reference to external entity in standalone document"); else if (value instanceof ExternalIds) { ExternalIds ids = (ExternalIds) value; if (ids.notationName != null && doctype.isNotationExternal(ids.notationName)) error("reference to external notation in " + "standalone document"); } } if (value instanceof String) { String text = (String) value; if (inAttr && text.indexOf('<') != -1) error("< in attribute value"); pushInput(name, text); } else if (inAttr) error("reference to external entity in attribute value", name); else pushInput(name, (ExternalIds) value); if (name != null) startEntityStack.addFirst(name); return; } } error("reference to undeclared entity", name); }
13,113
private void expandEntity(String name, boolean inAttr) throws IOException, XMLStreamException { if (doctype != null) { Object value = doctype.getEntity(name); if (value != null) { if (xmlStandalone == Boolean.TRUE) { if (doctype.isEntityExternal(name)) error("reference to external entity in standalone document"); else if (value instanceof ExternalIds) { ExternalIds ids = (ExternalIds) value; if (ids.notationName != null && doctype.isNotationExternal(ids.notationName)) error("reference to external notation in " + "standalone document"); } } if (value instanceof String) { String text = (String) value; if (inAttr && text.indexOf('<') != -1) error("< in attribute value"); pushInput(name, text); } else if (inAttr) error("reference to external entity in attribute value", name); else pushInput(name, (ExternalIds) value); if (name != null) startEntityStack.addFirst(name); return; } } error("reference to undeclared entity", name); }
private void expandEntity(String name, boolean inAttr) throws IOException, XMLStreamException { if (doctype != null) { Object value = doctype.getEntity(name); if (value != null) { if (xmlStandalone == Boolean.TRUE) { if (doctype.isEntityExternal(name)) error("reference to external entity in standalone document"); else if (value instanceof ExternalIds) { ExternalIds ids = (ExternalIds) value; if (ids.notationName != null && doctype.isNotationExternal(ids.notationName)) error("reference to external notation in " + "standalone document"); } } if (value instanceof String) { String text = (String) value; if (inAttr && text.indexOf('<') != -1) error("< in attribute value"); pushInput(name, text, !inAttr, normalize); } else if (inAttr) error("reference to external entity in attribute value", name); else pushInput(name, (ExternalIds) value); if (name != null) startEntityStack.addFirst(name); return; } } error("reference to undeclared entity", name); }
13,114
private void expandEntity(String name, boolean inAttr) throws IOException, XMLStreamException { if (doctype != null) { Object value = doctype.getEntity(name); if (value != null) { if (xmlStandalone == Boolean.TRUE) { if (doctype.isEntityExternal(name)) error("reference to external entity in standalone document"); else if (value instanceof ExternalIds) { ExternalIds ids = (ExternalIds) value; if (ids.notationName != null && doctype.isNotationExternal(ids.notationName)) error("reference to external notation in " + "standalone document"); } } if (value instanceof String) { String text = (String) value; if (inAttr && text.indexOf('<') != -1) error("< in attribute value"); pushInput(name, text); } else if (inAttr) error("reference to external entity in attribute value", name); else pushInput(name, (ExternalIds) value); if (name != null) startEntityStack.addFirst(name); return; } } error("reference to undeclared entity", name); }
private void expandEntity(String name, boolean inAttr) throws IOException, XMLStreamException { if (doctype != null) { Object value = doctype.getEntity(name); if (value != null) { if (xmlStandalone == Boolean.TRUE) { if (doctype.isEntityExternal(name)) error("reference to external entity in standalone document"); else if (value instanceof ExternalIds) { ExternalIds ids = (ExternalIds) value; if (ids.notationName != null && doctype.isNotationExternal(ids.notationName)) error("reference to external notation in " + "standalone document"); } } if (value instanceof String) { String text = (String) value; if (inAttr && text.indexOf('<') != -1) error("< in attribute value"); pushInput(name, text); } else if (inAttr) error("reference to external entity in attribute value", name); else pushInput(name, (ExternalIds) value); if (name != null) startEntityStack.addFirst(name); return; } } error("reference to undeclared entity", name); }
13,115
public String getEncoding() { if (input.forceReader) return null; return (input.inputEncoding == null) ? "UTF-8" : input.inputEncoding; }
public String getEncoding() { if (input.forceReader) return null; return (input.inputEncoding == null) ? "UTF-8" : input.inputEncoding; }
13,116
private boolean isNameCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && (c < 0x0030 || c > 0x0039) && c != ':' && c != '_' && c != '-' && c != '.' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff) && c != 0x00b7 && (c < 0x0300 || c > 0x036f) && (c < 0x203f || c > 0x2040)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.DECIMAL_DIGIT_NUMBER: // Nd case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl case Character.COMBINING_SPACING_MARK: // Mc case Character.ENCLOSING_MARK: // Me case Character.NON_SPACING_MARK: // Mn case Character.MODIFIER_LETTER: // Lm if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) return false; break; default: if (c != '-' && c != '.' && c != ':' && c != '_' && c != 0x0387 && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) return false; } } return true; }
private boolean isNameCharacter(int c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && (c < 0x0030 || c > 0x0039) && c != ':' && c != '_' && c != '-' && c != '.' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff) && c != 0x00b7 && (c < 0x0300 || c > 0x036f) && (c < 0x203f || c > 0x2040)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.DECIMAL_DIGIT_NUMBER: // Nd case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl case Character.COMBINING_SPACING_MARK: // Mc case Character.ENCLOSING_MARK: // Me case Character.NON_SPACING_MARK: // Mn case Character.MODIFIER_LETTER: // Lm if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) return false; break; default: if (c != '-' && c != '.' && c != ':' && c != '_' && c != 0x0387 && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) return false; } } return true; }
13,121
private boolean isNameCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && (c < 0x0030 || c > 0x0039) && c != ':' && c != '_' && c != '-' && c != '.' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff) && c != 0x00b7 && (c < 0x0300 || c > 0x036f) && (c < 0x203f || c > 0x2040)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.DECIMAL_DIGIT_NUMBER: // Nd case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl case Character.COMBINING_SPACING_MARK: // Mc case Character.ENCLOSING_MARK: // Me case Character.NON_SPACING_MARK: // Mn case Character.MODIFIER_LETTER: // Lm if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) return false; break; default: if (c != '-' && c != '.' && c != ':' && c != '_' && c != 0x0387 && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) return false; } } return true; }
private boolean isNameCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && (c < 0x0030 || c > 0x0039) && c != ':' && c != '_' && c != '-' && c != '.' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff) && c != 0x00b7 && (c < 0x0300 || c > 0x036f) && (c < 0x203f || c > 0x2040)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.DECIMAL_DIGIT_NUMBER: // Nd case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl case Character.COMBINING_SPACING_MARK: // Mc case Character.ENCLOSING_MARK: // Me case Character.NON_SPACING_MARK: // Mn case Character.MODIFIER_LETTER: // Lm if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) return false; break; default: if (c != '-' && c != '.' && c != ':' && c != '_' && c != 0x0387 && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) return false; } } return true; }
13,122
private boolean isNameCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && (c < 0x0030 || c > 0x0039) && c != ':' && c != '_' && c != '-' && c != '.' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff) && c != 0x00b7 && (c < 0x0300 || c > 0x036f) && (c < 0x203f || c > 0x2040)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.DECIMAL_DIGIT_NUMBER: // Nd case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl case Character.COMBINING_SPACING_MARK: // Mc case Character.ENCLOSING_MARK: // Me case Character.NON_SPACING_MARK: // Mn case Character.MODIFIER_LETTER: // Lm if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) return false; break; default: if (c != '-' && c != '.' && c != ':' && c != '_' && c != 0x0387 && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) return false; } } return true; }
private boolean isNameCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && (c < 0x0030 || c > 0x0039) && c != ':' && c != '_' && c != '-' && c != '.' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff) && c != 0x00b7 && (c < 0x0300 || c > 0x036f) && (c < 0x203f || c > 0x2040)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.DECIMAL_DIGIT_NUMBER: // Nd case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl case Character.COMBINING_SPACING_MARK: // Mc case Character.ENCLOSING_MARK: // Me case Character.NON_SPACING_MARK: // Mn case Character.MODIFIER_LETTER: // Lm if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) return false; break; default: if (c != '-' && c != '.' && c != ':' && c != '_' && c != 0x0387 && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6 && c != 0x00b7) return false; } } return true; }
13,123
private boolean isNameStartCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && c != ':' && c != '_' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) { // Compatibility area and Unicode 2.0 exclusions return false; } break; default: if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6) return false; } } return true; }
private boolean isNameStartCharacter(int c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && c != ':' && c != '_' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) { // Compatibility area and Unicode 2.0 exclusions return false; } break; default: if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6) return false; } } return true; }
13,124
private boolean isNameStartCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && c != ':' && c != '_' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) { // Compatibility area and Unicode 2.0 exclusions return false; } break; default: if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6) return false; } } return true; }
private boolean isNameStartCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && c != ':' && c != '_' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) { // Compatibility area and Unicode 2.0 exclusions return false; } break; default: if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6) return false; } } return true; }
13,125
private boolean isNameStartCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && c != ':' && c != '_' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) { // Compatibility area and Unicode 2.0 exclusions return false; } break; default: if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6) return false; } } return true; }
private boolean isNameStartCharacter(char c) { if (input.xml11) { if ((c < 0x0041 || c > 0x005a) && (c < 0x0061 || c > 0x007a) && c != ':' && c != '_' && (c < 0x00c0 || c > 0x00d6) && (c < 0x00d8 || c > 0x00f6) && (c < 0x00f8 || c > 0x02ff) && (c < 0x0370 || c > 0x037d) && (c < 0x037f || c > 0x1fff) && (c < 0x200c || c > 0x200d) && (c < 0x2070 || c > 0x218f) && (c < 0x2c00 || c > 0x2fef) && (c < 0x3001 || c > 0xd7ff) && (c < 0xf900 || c > 0xfdcf) && (c < 0xfdf0 || c > 0xfffd) && (c < 0x10000 || c > 0xeffff)) return false; } else { int type = Character.getType(c); switch (type) { case Character.LOWERCASE_LETTER: // Ll case Character.UPPERCASE_LETTER: // Lu case Character.OTHER_LETTER: // Lo case Character.TITLECASE_LETTER: // Lt case Character.LETTER_NUMBER: // Nl if ((c > 0xf900 && c < 0xfffe) || (c >= 0x20dd && c <= 0x20e0)) { // Compatibility area and Unicode 2.0 exclusions return false; } break; default: if (c != ':' && c != '_' && (c < 0x02bb || c > 0x02c1) && c != 0x0559 && c != 0x06e5 && c != 0x06e6) return false; } } return true; }
13,126
private char literalReadCh() throws IOException, XMLStreamException { char c = readCh(); while (c == '\uffff') { if (inputStack.size() > 1) { inputStack.removeLast(); input = (Input) inputStack.getLast(); // Don't issue end-entity c = readCh(); } else throw new EOFException(); } return c; }
private int literalReadCh(boolean recognizePEs) throws IOException, XMLStreamException { char c = readCh(); while (c == '\uffff') { if (inputStack.size() > 1) { inputStack.removeLast(); input = (Input) inputStack.getLast(); // Don't issue end-entity c = readCh(); } else throw new EOFException(); } return c; }
13,127
private char literalReadCh() throws IOException, XMLStreamException { char c = readCh(); while (c == '\uffff') { if (inputStack.size() > 1) { inputStack.removeLast(); input = (Input) inputStack.getLast(); // Don't issue end-entity c = readCh(); } else throw new EOFException(); } return c; }
private char literalReadCh() throws IOException, XMLStreamException { char c = readCh(); while (c == '\uffff') { if (inputStack.size() > 1) { inputStack.removeLast(); input = (Input) inputStack.getLast(); // Don't issue end-entity c = readCh(); } else throw new EOFException(); } return c; }
13,128
private char literalReadCh() throws IOException, XMLStreamException { char c = readCh(); while (c == '\uffff') { if (inputStack.size() > 1) { inputStack.removeLast(); input = (Input) inputStack.getLast(); // Don't issue end-entity c = readCh(); } else throw new EOFException(); } return c; }
private char literalReadCh() throws IOException, XMLStreamException { char c = recognizePEs ? readCh() : read(); while (c == '\uffff') { if (inputStack.size() > 1) { inputStack.removeLast(); input = (Input) inputStack.getLast(); // Don't issue end-entity c = recognizePEs ? readCh() : read(); } else throw new EOFException(); } return c; }
13,129
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), true, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD true, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
13,130
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+encodeText(reader.getText())+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
13,131
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+encodeText(reader.getText())+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
13,132
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+encodeText(reader.getText())+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
13,133
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+reader.getText()+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
public static void main(String[] args) throws Exception { boolean xIncludeAware = false; if (args.length > 1 && "-x".equals(args[1])) xIncludeAware = true; XMLParser p = new XMLParser(new java.io.FileInputStream(args[0]), absolutize(null, args[0]), false, // validating true, // namespaceAware true, // coalescing, true, // replaceERefs true, // externalEntities true, // supportDTD false, // baseAware true, // stringInterning null, null); XMLStreamReader reader = p; if (xIncludeAware) reader = new XIncludeFilter(p, args[0], true, true, true); try { int event; //do while (reader.hasNext()) { event = reader.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: System.out.println("START_DOCUMENT version="+reader.getVersion()+ " encoding="+reader.getEncoding()); break; case XMLStreamConstants.END_DOCUMENT: System.out.println("END_DOCUMENT"); break; case XMLStreamConstants.START_ELEMENT: System.out.println("START_ELEMENT "+reader.getName()); int l = reader.getNamespaceCount(); for (int i = 0; i < l; i++) System.out.println("\tnamespace "+reader.getNamespacePrefix(i)+ "='"+reader.getNamespaceURI(i)+"'"); l = reader.getAttributeCount(); for (int i = 0; i < l; i++) System.out.println("\tattribute "+reader.getAttributeQName(i)+ "='"+reader.getAttributeValue(i)+"'"); break; case XMLStreamConstants.END_ELEMENT: System.out.println("END_ELEMENT "+reader.getName()); break; case XMLStreamConstants.CHARACTERS: System.out.println("CHARACTERS '"+reader.getText()+"'"); break; case XMLStreamConstants.CDATA: System.out.println("CDATA '"+reader.getText()+"'"); break; case XMLStreamConstants.SPACE: System.out.println("SPACE '"+reader.getText()+"'"); break; case XMLStreamConstants.DTD: System.out.println("DTD "+reader.getText()); break; case XMLStreamConstants.ENTITY_REFERENCE: System.out.println("ENTITY_REFERENCE "+reader.getText()); break; case XMLStreamConstants.COMMENT: System.out.println("COMMENT '"+encodeText(reader.getText())+"'"); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: System.out.println("PROCESSING_INSTRUCTION "+reader.getPITarget()+ " "+reader.getPIData()); break; case XMLStreamConstants.START_ENTITY: System.out.println("START_ENTITY "+reader.getText()); break; case XMLStreamConstants.END_ENTITY: System.out.println("END_ENTITY "+reader.getText()); break; default: System.out.println("Unknown event: "+event); } } //while (event != XMLStreamConstants.END_DOCUMENT); } catch (XMLStreamException e) { Location l = reader.getLocation(); System.out.println("At line "+l.getLineNumber()+ ", column "+l.getColumnNumber()+ " of "+l.getLocationURI()); throw e; } }
13,134
private void popInput() { Input old = (Input) inputStack.removeLast(); if (!"".equals(old.name)) endEntityStack.addFirst(old.name); input = (Input) inputStack.getLast(); //System.out.print("\n(-input:"+input.systemId+")"); //System.out.println("popInput "+old.name); }
private void popInput() { Input old = (Input) inputStack.removeLast(); if (old.report) endEntityStack.addFirst(old.name); input = (Input) inputStack.getLast(); //System.out.print("\n(-input:"+input.systemId+")"); //System.out.println("popInput "+old.name); }
13,135
private void pushInput(String name, String text) throws IOException, XMLStreamException { // Check for recursion for (Iterator i = inputStack.iterator(); i.hasNext(); ) { Input ctx = (Input) i.next(); if (name.equals(ctx.name)) error("entities may not be self-recursive", name); } pushInput(new Input(null, new StringReader(text), input.publicId, input.systemId, name, input.inputEncoding)); //System.out.println("pushInput "+name+" "+text); }
private void pushInput(String name, String text, boolean report, boolean normalize) throws IOException, XMLStreamException { // Check for recursion for (Iterator i = inputStack.iterator(); i.hasNext(); ) { Input ctx = (Input) i.next(); if (name.equals(ctx.name)) error("entities may not be self-recursive", name); } pushInput(new Input(null, new StringReader(text), input.publicId, input.systemId, name, input.inputEncoding)); //System.out.println("pushInput "+name+" "+text); }
13,136
private void pushInput(String name, String text) throws IOException, XMLStreamException { // Check for recursion for (Iterator i = inputStack.iterator(); i.hasNext(); ) { Input ctx = (Input) i.next(); if (name.equals(ctx.name)) error("entities may not be self-recursive", name); } pushInput(new Input(null, new StringReader(text), input.publicId, input.systemId, name, input.inputEncoding)); //System.out.println("pushInput "+name+" "+text); }
private void pushInput(String name, String text) throws IOException, XMLStreamException { // Check for recursion for (Iterator i = inputStack.iterator(); i.hasNext(); ) { Input ctx = (Input) i.next(); if (name.equals(ctx.name)) error("entities may not be self-recursive", name); } pushInput(new Input(null, new StringReader(text), input.publicId, input.systemId, name, input.inputEncoding, report, normalize)); //System.out.println("pushInput "+name+" "+text); }
13,137
private int read() throws IOException { int ret = input.read(); //System.out.println("read1:"+(char) ret); return ret; }
private int read() throws IOException { int ret = input.read(); //System.out.println("read1:"+(char) ret); return ret; }
13,138
private void readAttDef(String elementName) throws IOException, XMLStreamException { String name = readNmtoken(true); requireWhitespace(); StringBuffer acc = new StringBuffer(); String type = readAttType(acc); String enumer = null; if ("ENUMERATION".equals(type) || "NOTATION".equals(type)) enumer = acc.toString(); requireWhitespace(); readDefault(elementName, name, type, enumer); }
private void readAttDef(String elementName) throws IOException, XMLStreamException { String name = readNmtoken(true); requireWhitespace(); StringBuffer acc = new StringBuffer(); HashSet values = new HashSet(); String type = readAttType(acc, values); if (validating) { if ("ID".equals(type)) { for (Iterator i = doctype.attlistIterator(elementName); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); AttributeDecl decl = (AttributeDecl) entry.getValue(); if ("ID".equals(decl.type)) error("element types must not have more than one ID " + "attribute"); } } else if ("NOTATION".equals(type)) { for (Iterator i = doctype.attlistIterator(elementName); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); AttributeDecl decl = (AttributeDecl) entry.getValue(); if ("NOTATION".equals(decl.type)) error("element types must not have more than one NOTATION " + "attribute"); } ContentModel model = doctype.getElementModel(elementName); if (model != null && model.type == ContentModel.EMPTY) error("attributes of type NOTATION must not be declared on an " + "element declared EMPTY"); } } String enumer = null; if ("ENUMERATION".equals(type) || "NOTATION".equals(type)) enumer = acc.toString(); requireWhitespace(); readDefault(elementName, name, type, enumer); }
13,139
private void readAttDef(String elementName) throws IOException, XMLStreamException { String name = readNmtoken(true); requireWhitespace(); StringBuffer acc = new StringBuffer(); String type = readAttType(acc); String enumer = null; if ("ENUMERATION".equals(type) || "NOTATION".equals(type)) enumer = acc.toString(); requireWhitespace(); readDefault(elementName, name, type, enumer); }
private void readAttDef(String elementName) throws IOException, XMLStreamException { String name = readNmtoken(true); requireWhitespace(); StringBuffer acc = new StringBuffer(); String type = readAttType(acc); String enumer = null; if ("ENUMERATION".equals(type) || "NOTATION".equals(type)) enumer = acc.toString(); requireWhitespace(); readDefault(elementName, name, type, enumer, values); }
13,140
private String readAttType(StringBuffer acc) throws IOException, XMLStreamException { if (tryRead('(')) { readEnumeration(false, acc); return "ENUMERATION"; } else { String typeString = readNmtoken(true); if ("NOTATION".equals(typeString)) { readNotationType(acc); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; else { error("illegal attribute type", typeString); return null; } } }
private String readAttType(StringBuffer acc, HashSet values) throws IOException, XMLStreamException { if (tryRead('(')) { readEnumeration(false, acc); return "ENUMERATION"; } else { String typeString = readNmtoken(true); if ("NOTATION".equals(typeString)) { readNotationType(acc); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; else { error("illegal attribute type", typeString); return null; } } }
13,141
private String readAttType(StringBuffer acc) throws IOException, XMLStreamException { if (tryRead('(')) { readEnumeration(false, acc); return "ENUMERATION"; } else { String typeString = readNmtoken(true); if ("NOTATION".equals(typeString)) { readNotationType(acc); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; else { error("illegal attribute type", typeString); return null; } } }
private String readAttType(StringBuffer acc) throws IOException, XMLStreamException { if (tryRead('(')) { readEnumeration(false, acc, values); return "ENUMERATION"; } else { String typeString = readNmtoken(true); if ("NOTATION".equals(typeString)) { readNotationType(acc); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; else { error("illegal attribute type", typeString); return null; } } }
13,142
private String readAttType(StringBuffer acc) throws IOException, XMLStreamException { if (tryRead('(')) { readEnumeration(false, acc); return "ENUMERATION"; } else { String typeString = readNmtoken(true); if ("NOTATION".equals(typeString)) { readNotationType(acc); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; else { error("illegal attribute type", typeString); return null; } } }
private String readAttType(StringBuffer acc) throws IOException, XMLStreamException { if (tryRead('(')) { readEnumeration(false, acc); return "ENUMERATION"; } else { String typeString = readNmtoken(true); if ("NOTATION".equals(typeString)) { readNotationType(acc, values); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; else { error("illegal attribute type", typeString); return null; } } }
13,143
private void readAttribute(String elementName) throws IOException, XMLStreamException { //System.err.println("readAttribute"); // Read attribute name String attributeName = readNmtoken(true); String type = getAttributeType(elementName, attributeName); readEq(); // Read literal final int flags = LIT_ATTRIBUTE | LIT_ENTITY_REF; String value = (type == null || "CDATA".equals(type)) ? readLiteral(flags) : readLiteral(flags | LIT_NORMALIZE); // add attribute event Attribute attr = this.new Attribute(attributeName, type, true, value); if (namespaceAware) { if (attributeName.equals(":")) error("XML Namespaces forbids names consisting of a single colon"); else if (attributeName.equals("xmlns")) { LinkedHashMap ctx = (LinkedHashMap) namespaces.getFirst(); if (ctx.containsKey(XMLConstants.DEFAULT_NS_PREFIX)) error("duplicate default namespace"); } else if (attributeName.startsWith("xmlns:")) { LinkedHashMap ctx = (LinkedHashMap) namespaces.getFirst(); if (ctx.containsKey(attributeName.substring(6))) error("duplicate namespace", attributeName.substring(6)); } else if (attrs.contains(attr)) error("duplicate attribute", attributeName); } else if (attrs.contains(attr)) error("duplicate attribute", attributeName); if (namespaceAware) { if (!addNamespace(attr)) attrs.add(attr); } else attrs.add(attr); }
private void readAttribute(String elementName) throws IOException, XMLStreamException { //System.err.println("readAttribute"); // Read attribute name String attributeName = readNmtoken(true); String type = getAttributeType(elementName, attributeName); readEq(); // Read literal final int flags = LIT_ATTRIBUTE | LIT_ENTITY_REF; String value = (type == null || "CDATA".equals(type)) ? readLiteral(flags, false) : readLiteral(flags | LIT_NORMALIZE, false); // add attribute event Attribute attr = this.new Attribute(attributeName, type, true, value); if (namespaceAware) { if (attributeName.equals(":")) error("XML Namespaces forbids names consisting of a single colon"); else if (attributeName.equals("xmlns")) { LinkedHashMap ctx = (LinkedHashMap) namespaces.getFirst(); if (ctx.containsKey(XMLConstants.DEFAULT_NS_PREFIX)) error("duplicate default namespace"); } else if (attributeName.startsWith("xmlns:")) { LinkedHashMap ctx = (LinkedHashMap) namespaces.getFirst(); if (ctx.containsKey(attributeName.substring(6))) error("duplicate namespace", attributeName.substring(6)); } else if (attrs.contains(attr)) error("duplicate attribute", attributeName); } else if (attrs.contains(attr)) error("duplicate attribute", attributeName); if (namespaceAware) { if (!addNamespace(attr)) attrs.add(attr); } else attrs.add(attr); }
13,144
private void readAttribute(String elementName) throws IOException, XMLStreamException { //System.err.println("readAttribute"); // Read attribute name String attributeName = readNmtoken(true); String type = getAttributeType(elementName, attributeName); readEq(); // Read literal final int flags = LIT_ATTRIBUTE | LIT_ENTITY_REF; String value = (type == null || "CDATA".equals(type)) ? readLiteral(flags) : readLiteral(flags | LIT_NORMALIZE); // add attribute event Attribute attr = this.new Attribute(attributeName, type, true, value); if (namespaceAware) { if (attributeName.equals(":")) error("XML Namespaces forbids names consisting of a single colon"); else if (attributeName.equals("xmlns")) { LinkedHashMap ctx = (LinkedHashMap) namespaces.getFirst(); if (ctx.containsKey(XMLConstants.DEFAULT_NS_PREFIX)) error("duplicate default namespace"); } else if (attributeName.startsWith("xmlns:")) { LinkedHashMap ctx = (LinkedHashMap) namespaces.getFirst(); if (ctx.containsKey(attributeName.substring(6))) error("duplicate namespace", attributeName.substring(6)); } else if (attrs.contains(attr)) error("duplicate attribute", attributeName); } else if (attrs.contains(attr)) error("duplicate attribute", attributeName); if (namespaceAware) { if (!addNamespace(attr)) attrs.add(attr); } else attrs.add(attr); }
private void readAttribute(String elementName) throws IOException, XMLStreamException { //System.err.println("readAttribute"); // Read attribute name String attributeName = readNmtoken(true); String type = getAttributeType(elementName, attributeName); readEq(); // Read literal final int flags = LIT_ATTRIBUTE | LIT_ENTITY_REF; String value = (type == null || "CDATA".equals(type)) ? readLiteral(flags) : readLiteral(flags | LIT_NORMALIZE); // add attribute event Attribute attr = this.new Attribute(attributeName, type, true, value); if (namespaceAware) { if (attributeName.equals(":")) error("XML Namespaces forbids names consisting of a single colon"); else if (attributeName.equals("xmlns")) { LinkedHashMap ctx = (LinkedHashMap) namespaces.getFirst(); if (ctx.containsKey(XMLConstants.DEFAULT_NS_PREFIX)) error("duplicate default namespace"); } else if (attributeName.startsWith("xmlns:")) { LinkedHashMap ctx = (LinkedHashMap) namespaces.getFirst(); if (ctx.containsKey(attributeName.substring(6))) error("duplicate namespace", attributeName.substring(6)); } else if (attrs.contains(attr)) error("duplicate attribute", attributeName); } else if (attrs.contains(attr)) error("duplicate attribute", attributeName); if (namespaceAware) { if (!addNamespace(attr)) attrs.add(attr); } else attrs.add(attr); }
13,145
private char readCh() throws IOException, XMLStreamException { char c = (char) read(); if (expandPE && c == '%') { if (peIsError) error("PE reference within decl in internal subset."); parsePEReference(); return readCh(); } return c; }
private int readCh() throws IOException, XMLStreamException { char c = (char) read(); if (expandPE && c == '%') { if (peIsError) error("PE reference within decl in internal subset."); parsePEReference(); return readCh(); } return c; }
13,147
private char readCh() throws IOException, XMLStreamException { char c = (char) read(); if (expandPE && c == '%') { if (peIsError) error("PE reference within decl in internal subset."); parsePEReference(); return readCh(); } return c; }
private char readCh() throws IOException, XMLStreamException { char c = (char) read(); if (expandPE && c == '%') { if (peIsError) error("PE reference within decl in internal subset."); parsePEReference(); return readCh(); } return c; }
13,148
private char readCh() throws IOException, XMLStreamException { char c = (char) read(); if (expandPE && c == '%') { if (peIsError) error("PE reference within decl in internal subset."); parsePEReference(); return readCh(); } return c; }
private char readCh() throws IOException, XMLStreamException { char c = (char) read(); if (expandPE && c == '%') { if (peIsError) error("PE reference within decl in internal subset."); expandPEReference(); return readCh(); } return c; }
13,149
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { int c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,150
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,151
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case 0x26: reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,152
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == 0x23) { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,153
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 0x78); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,154
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,155
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";", false, false); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,156
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case 0x3e: int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,157
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(Character.toChars(c)); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(Character.toChars(c)); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(Character.toChars(c)); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,158
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case 0x3c: reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,159
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
private int readCharData(String prefix) throws IOException, XMLStreamException { boolean white = true; buf.setLength(0); if (prefix != null) buf.append(prefix); boolean done = false; boolean entities = false; //System.out.println("readCharData input="+input.name+" line="+input.line+" col="+input.column); while (!done) { // Block read mark(tmpBuf.length); int len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); // report end-entity done = true; } else throw new EOFException(); } for (int i = 0; i < len && !done; i++) { char c = tmpBuf[i]; switch (c) { case ' ': case '\t': case '\n': case '\r': buf.append(c); break; // whitespace case '&': reset(); read(tmpBuf, 0, i); // character reference? mark(3); c = readCh(); // & c = readCh(); if (c == '#') { mark(1); c = readCh(); boolean hex = (c == 'x'); if (!hex) reset(); char[] ch = readCharacterRef(hex ? 16 : 10); buf.append(ch, 0, ch.length); for (int j = 0; j < ch.length; j++) { switch (ch[j]) { case ' ': case '\t': case '\n': case '\r': break; // whitespace default: white = false; } } } else { // entity reference reset(); c = readCh(); // & String entityName = readNmtoken(true); require(';'); String text = (String) PREDEFINED_ENTITIES.get(entityName); if (text != null) buf.append(text); else { //if (replaceERefs) // expandEntity(entityName, false); //report start-entity //else // reset(); // report reference pushInput("", "&" + entityName + ";"); done = true; break; } } // continue processing i = -1; mark(tmpBuf.length); len = read(tmpBuf, 0, tmpBuf.length); if (len == -1) { if (inputStack.size() > 1) { popInput(); done = true; } else throw new EOFException(); } entities = true; break; // end of text sequence case '>': int l = buf.length(); if (l > 1 && buf.charAt(l - 1) == ']' && buf.charAt(l - 2) == ']') error("Character data may not contain unescaped ']]>'"); buf.append(c); break; case '<': reset(); read(tmpBuf, 0, i); done = true; break; // end of text sequence default: if ((c < 0x0020 || c > 0xfffd) || (input.xml11 && (c >= 0x007f) && (c <= 0x009f) && (c != 0x0085))) { error("illegal XML character", "U+" + Integer.toHexString(c)); } white = false; buf.append(c); } } // if text buffer >= 2MB, return it as a chunk // to avoid excessive memory use if (!coalescing && buf.length() >= 2097152) done = true; } if (entities) normalizeCRLF(buf); return white ? XMLStreamConstants.SPACE : XMLStreamConstants.CHARACTERS; }
13,160