rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
executeMeMacro(e); }
screen.sendKeys("[field-]"); }
public void actionPerformed(ActionEvent e) { executeMeMacro(e); }
doMeTransfer();
screen.sendKeys("[newline]");
public void actionPerformed(ActionEvent e) { doMeTransfer(); }
sendScreenEMail();
vt.hostPrint(1);
public void actionPerformed(ActionEvent e) { sendScreenEMail(); }
sendMeToFile(); }
vt.systemRequest('4'); }
public void actionPerformed(ActionEvent e) { sendMeToFile(); }
vt.disconnect(); getFocusForMe(); }
showHexMap(); }
public void actionPerformed(ActionEvent e) { vt.disconnect(); getFocusForMe(); }
vt.connect(); getFocusForMe(); }
mapMeKeys(); }
public void actionPerformed(ActionEvent e) { vt.connect(); getFocusForMe(); }
closeSession(); }
doAttributes(); }
public void actionPerformed(ActionEvent e) { closeSession(); }
if (keyProcessed || e.isConsumed())
if (Character.isISOControl(e.getKeyChar()) || keyProcessed || e.isConsumed() )
private void processVTKeyReleased(KeyEvent e){ if (isLinux && e.getKeyCode() == e.VK_ALT_GRAPH) { isAltGr = false; }// displayInfo(e,"Released " + keyProcessed); if (keyProcessed || e.isConsumed()) return; String s = keyMap.getKeyStrokeText(e); if (s != null) { if (s.startsWith("[")) { screen.sendKeys(s); if (recording) recordBuffer.append(s); } else executeMeMacro(s); } else keyProcessed = false; if (keyProcessed) e.consume(); }
if (Character.isISOControl(kc) || keyProcessed)
if (Character.isISOControl(kc) || keyProcessed) {
private void processVTKeyTyped(KeyEvent e){ char kc = e.getKeyChar();// displayInfo(e,"Typed processed " + keyProcessed); if (Character.isISOControl(kc) || keyProcessed)// if (keyProcessed) return;// displayInfo(e,"Typed "); String s = "";// if (isLinux) {// lastKeyStroke = keyMap.getKeyStrokeText(e,isAltGr);// System.out.println("last " + lastKeyStroke);// if (lastKeyStroke != null) {// s = lastKeyStroke;// System.out.println("last " + s);// }// else// s +=kc;// }// else s += kc; if (!vt.isConnected() ) return; screen.sendKeys(s); if (recording) recordBuffer.append(s); keyProcessed = true; e.consume(); }
}
private void processVTKeyTyped(KeyEvent e){ char kc = e.getKeyChar();// displayInfo(e,"Typed processed " + keyProcessed); if (Character.isISOControl(kc) || keyProcessed)// if (keyProcessed) return;// displayInfo(e,"Typed "); String s = "";// if (isLinux) {// lastKeyStroke = keyMap.getKeyStrokeText(e,isAltGr);// System.out.println("last " + lastKeyStroke);// if (lastKeyStroke != null) {// s = lastKeyStroke;// System.out.println("last " + s);// }// else// s +=kc;// }// else s += kc; if (!vt.isConnected() ) return; screen.sendKeys(s); if (recording) recordBuffer.append(s); keyProcessed = true; e.consume(); }
return super.getAttributes();
if (attributes == null) { attributes = getStyleSheet().getViewAttributes(this); } return attributes;
public AttributeSet getAttributes() { // FIXME: Implement this multiplexing thing. return super.getAttributes(); }
}
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 13, y); g.drawLine(x + 14, y + 1, x + 14, y + 7); g.drawLine(x + 14, y + 8, x + 7, y + 15); g.drawLine(x + 6, y + 14, x, y + 8); g.drawLine(x, y + 7, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 12, 7); g.drawLine(x + 2, y + 9, x + 12, y + 9); g.drawLine(x + 3, y + 10, x + 11, y + 10); g.drawLine(x + 4, y + 11, x + 10, y + 11); g.drawLine(x + 5, y + 12, x + 9, y + 12); g.drawLine(x + 6, y + 13, x + 8, y + 13); g.drawLine(x + 7, y + 14, x + 7, y + 14); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 13, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 8); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 10, y + 2, x + 10, y + 2); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 8, y + 4, x + 8, y + 4); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 10, y + 6, x + 10, y + 6); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 11, y + 3, x + 11, y + 3); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 9, y + 5, x + 9, y + 5); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 11, y + 7, x + 11, y + 7); }
g.setColor(Color.black);
if (enabled) g.setColor(MetalLookAndFeel.getBlack()); else g.setColor(MetalLookAndFeel.getControlDarkShadow());
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 13, y); g.drawLine(x + 14, y + 1, x + 14, y + 7); g.drawLine(x + 14, y + 8, x + 7, y + 15); g.drawLine(x + 6, y + 14, x, y + 8); g.drawLine(x, y + 7, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 12, 7); g.drawLine(x + 2, y + 9, x + 12, y + 9); g.drawLine(x + 3, y + 10, x + 11, y + 10); g.drawLine(x + 4, y + 11, x + 10, y + 11); g.drawLine(x + 5, y + 12, x + 9, y + 12); g.drawLine(x + 6, y + 13, x + 8, y + 13); g.drawLine(x + 7, y + 14, x + 7, y + 14); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 13, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 8); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 10, y + 2, x + 10, y + 2); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 8, y + 4, x + 8, y + 4); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 10, y + 6, x + 10, y + 6); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 11, y + 3, x + 11, y + 3); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 9, y + 5, x + 9, y + 5); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 11, y + 7, x + 11, y + 7); }
g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); g.fillRect(x + 2, y + 2, 12, 7);
if (focus) g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); else g.setColor(MetalLookAndFeel.getControl()); g.fillRect(x + 1, y + 2, 13, 7);
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 13, y); g.drawLine(x + 14, y + 1, x + 14, y + 7); g.drawLine(x + 14, y + 8, x + 7, y + 15); g.drawLine(x + 6, y + 14, x, y + 8); g.drawLine(x, y + 7, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 12, 7); g.drawLine(x + 2, y + 9, x + 12, y + 9); g.drawLine(x + 3, y + 10, x + 11, y + 10); g.drawLine(x + 4, y + 11, x + 10, y + 11); g.drawLine(x + 5, y + 12, x + 9, y + 12); g.drawLine(x + 6, y + 13, x + 8, y + 13); g.drawLine(x + 7, y + 14, x + 7, y + 14); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 13, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 8); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 10, y + 2, x + 10, y + 2); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 8, y + 4, x + 8, y + 4); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 10, y + 6, x + 10, y + 6); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 11, y + 3, x + 11, y + 3); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 9, y + 5, x + 9, y + 5); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 11, y + 7, x + 11, y + 7); }
g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255));
if (focus) g.setColor(MetalLookAndFeel.getPrimaryControl()); else g.setColor(MetalLookAndFeel.getWhite());
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 13, y); g.drawLine(x + 14, y + 1, x + 14, y + 7); g.drawLine(x + 14, y + 8, x + 7, y + 15); g.drawLine(x + 6, y + 14, x, y + 8); g.drawLine(x, y + 7, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 12, 7); g.drawLine(x + 2, y + 9, x + 12, y + 9); g.drawLine(x + 3, y + 10, x + 11, y + 10); g.drawLine(x + 4, y + 11, x + 10, y + 11); g.drawLine(x + 5, y + 12, x + 9, y + 12); g.drawLine(x + 6, y + 13, x + 8, y + 13); g.drawLine(x + 7, y + 14, x + 7, y + 14); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 13, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 8); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 10, y + 2, x + 10, y + 2); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 8, y + 4, x + 8, y + 4); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 10, y + 6, x + 10, y + 6); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 11, y + 3, x + 11, y + 3); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 9, y + 5, x + 9, y + 5); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 11, y + 7, x + 11, y + 7); }
g.setColor(focus ? new Color(102, 102, 153) : Color.black); g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 11, y + 3, x + 11, y + 3); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 9, y + 5, x + 9, y + 5); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 11, y + 7, x + 11, y + 7);
}
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 13, y); g.drawLine(x + 14, y + 1, x + 14, y + 7); g.drawLine(x + 14, y + 8, x + 7, y + 15); g.drawLine(x + 6, y + 14, x, y + 8); g.drawLine(x, y + 7, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 12, 7); g.drawLine(x + 2, y + 9, x + 12, y + 9); g.drawLine(x + 3, y + 10, x + 11, y + 10); g.drawLine(x + 4, y + 11, x + 10, y + 11); g.drawLine(x + 5, y + 12, x + 9, y + 12); g.drawLine(x + 6, y + 13, x + 8, y + 13); g.drawLine(x + 7, y + 14, x + 7, y + 14); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 13, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 8); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 10, y + 2, x + 10, y + 2); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 8, y + 4, x + 8, y + 4); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 10, y + 6, x + 10, y + 6); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 11, y + 3, x + 11, y + 3); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 9, y + 5, x + 9, y + 5); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 11, y + 7, x + 11, y + 7); }
Color dark = MetalLookAndFeel.getControlDarkShadow(); Color light = MetalLookAndFeel.getWhite(); g.translate(x, y);
Color savedColor = g.getColor(); JRadioButton b = (JRadioButton) c;
public void paintIcon(Component c, Graphics g, int x, int y) { Color dark = MetalLookAndFeel.getControlDarkShadow(); Color light = MetalLookAndFeel.getWhite(); g.translate(x, y); // The light 'circle' g.setColor(light); g.drawLine(4, 1, 10, 1); g.drawLine(2, 2, 3, 2); g.drawLine(8, 2, 11, 2); g.drawLine(2, 3, 2, 3); g.drawLine(11, 2, 11, 9); g.drawLine(1, 4, 1, 7); g.drawLine(12, 4, 12, 7); g.drawLine(2, 8, 2, 11); g.drawLine(11, 8, 11, 9); g.drawLine(10, 10, 10, 10); g.drawLine(2, 11, 9, 11); g.drawLine(4, 12, 7, 12); // The dark 'circle' g.setColor(dark); g.drawLine(4, 0, 7, 0); g.drawLine(2, 1, 3, 1); g.drawLine(8, 1, 9, 1); g.drawLine(1, 2, 1, 3); g.drawLine(10, 2, 10, 3); g.drawLine(0, 4, 0, 7); g.drawLine(11, 4, 11, 7); g.drawLine(1, 8, 1, 9); g.drawLine(10, 8, 10, 9); g.drawLine(2, 10, 3, 10); g.drawLine(8, 10, 9, 10); g.drawLine(4, 11, 7, 11); JRadioButton rb = (JRadioButton) c; if (rb.isSelected()) drawCheck(c, g); g.translate(-x, -y); }
g.setColor(light); g.drawLine(4, 1, 10, 1); g.drawLine(2, 2, 3, 2); g.drawLine(8, 2, 11, 2); g.drawLine(2, 3, 2, 3); g.drawLine(11, 2, 11, 9); g.drawLine(1, 4, 1, 7); g.drawLine(12, 4, 12, 7); g.drawLine(2, 8, 2, 11); g.drawLine(11, 8, 11, 9); g.drawLine(10, 10, 10, 10); g.drawLine(2, 11, 9, 11); g.drawLine(4, 12, 7, 12);
if (b.isEnabled()) g.setColor(MetalLookAndFeel.getControlDarkShadow()); else g.setColor(MetalLookAndFeel.getControlDisabled()); g.drawLine(x + 2, y + 1, x + 3, y + 1); g.drawLine(x + 4, y, x + 7, y); g.drawLine(x + 8, y + 1, x + 9, y + 1); g.drawLine(x + 10, y + 2, x + 10, y + 3); g.drawLine(x + 11, y + 4, x + 11, y + 7); g.drawLine(x + 10, y + 8, x + 10, y + 9); g.drawLine(x + 8, y + 10, x + 9, y + 10); g.drawLine(x + 4, y + 11, x + 7, y + 11); g.drawLine(x + 2, y + 10, x + 3, y + 10); g.drawLine(x + 1, y + 9, x + 1, y + 8); g.drawLine(x, y + 7, x, y + 4); g.drawLine(x + 1, y + 2, x + 1, y + 3);
public void paintIcon(Component c, Graphics g, int x, int y) { Color dark = MetalLookAndFeel.getControlDarkShadow(); Color light = MetalLookAndFeel.getWhite(); g.translate(x, y); // The light 'circle' g.setColor(light); g.drawLine(4, 1, 10, 1); g.drawLine(2, 2, 3, 2); g.drawLine(8, 2, 11, 2); g.drawLine(2, 3, 2, 3); g.drawLine(11, 2, 11, 9); g.drawLine(1, 4, 1, 7); g.drawLine(12, 4, 12, 7); g.drawLine(2, 8, 2, 11); g.drawLine(11, 8, 11, 9); g.drawLine(10, 10, 10, 10); g.drawLine(2, 11, 9, 11); g.drawLine(4, 12, 7, 12); // The dark 'circle' g.setColor(dark); g.drawLine(4, 0, 7, 0); g.drawLine(2, 1, 3, 1); g.drawLine(8, 1, 9, 1); g.drawLine(1, 2, 1, 3); g.drawLine(10, 2, 10, 3); g.drawLine(0, 4, 0, 7); g.drawLine(11, 4, 11, 7); g.drawLine(1, 8, 1, 9); g.drawLine(10, 8, 10, 9); g.drawLine(2, 10, 3, 10); g.drawLine(8, 10, 9, 10); g.drawLine(4, 11, 7, 11); JRadioButton rb = (JRadioButton) c; if (rb.isSelected()) drawCheck(c, g); g.translate(-x, -y); }
g.setColor(dark); g.drawLine(4, 0, 7, 0); g.drawLine(2, 1, 3, 1); g.drawLine(8, 1, 9, 1); g.drawLine(1, 2, 1, 3); g.drawLine(10, 2, 10, 3); g.drawLine(0, 4, 0, 7); g.drawLine(11, 4, 11, 7); g.drawLine(1, 8, 1, 9); g.drawLine(10, 8, 10, 9); g.drawLine(2, 10, 3, 10); g.drawLine(8, 10, 9, 10); g.drawLine(4, 11, 7, 11);
if (b.getModel().isArmed()) { g.setColor(MetalLookAndFeel.getControlShadow()); g.drawLine(x + 4, y + 1, x + 7, y + 1); g.drawLine(x + 4, y + 10, x + 7, y + 10); g.drawLine(x + 1, y + 4, x + 1, y + 7); g.drawLine(x + 10, y + 4, x + 10, y + 7); g.fillRect(x + 2, y + 2, 8, 8); } else { if (b.isEnabled()) { g.setColor(MetalLookAndFeel.getWhite()); g.drawLine(x + 2, y + 8, x + 2, y + 9); g.drawLine(x + 1, y + 4, x + 1, y + 7); g.drawLine(x + 2, y + 2, x + 2, y + 3); g.drawLine(x + 3, y + 2, x + 3, y + 2); g.drawLine(x + 4, y + 1, x + 7, y + 1); g.drawLine(x + 8, y + 2, x + 9, y + 2); } }
public void paintIcon(Component c, Graphics g, int x, int y) { Color dark = MetalLookAndFeel.getControlDarkShadow(); Color light = MetalLookAndFeel.getWhite(); g.translate(x, y); // The light 'circle' g.setColor(light); g.drawLine(4, 1, 10, 1); g.drawLine(2, 2, 3, 2); g.drawLine(8, 2, 11, 2); g.drawLine(2, 3, 2, 3); g.drawLine(11, 2, 11, 9); g.drawLine(1, 4, 1, 7); g.drawLine(12, 4, 12, 7); g.drawLine(2, 8, 2, 11); g.drawLine(11, 8, 11, 9); g.drawLine(10, 10, 10, 10); g.drawLine(2, 11, 9, 11); g.drawLine(4, 12, 7, 12); // The dark 'circle' g.setColor(dark); g.drawLine(4, 0, 7, 0); g.drawLine(2, 1, 3, 1); g.drawLine(8, 1, 9, 1); g.drawLine(1, 2, 1, 3); g.drawLine(10, 2, 10, 3); g.drawLine(0, 4, 0, 7); g.drawLine(11, 4, 11, 7); g.drawLine(1, 8, 1, 9); g.drawLine(10, 8, 10, 9); g.drawLine(2, 10, 3, 10); g.drawLine(8, 10, 9, 10); g.drawLine(4, 11, 7, 11); JRadioButton rb = (JRadioButton) c; if (rb.isSelected()) drawCheck(c, g); g.translate(-x, -y); }
JRadioButton rb = (JRadioButton) c; if (rb.isSelected()) drawCheck(c, g); g.translate(-x, -y);
if (b.isEnabled()) { g.setColor(MetalLookAndFeel.getWhite()); g.drawLine(x + 10, y + 1, x + 10, y + 1); g.drawLine(x + 11, y + 2, x + 11, y + 3); g.drawLine(x + 12, y + 4, x + 12, y + 7); g.drawLine(x + 11, y + 8, x + 11, y + 9); g.drawLine(x + 10, y + 10, x + 10, y + 10); g.drawLine(x + 8, y + 11, x + 9, y + 11); g.drawLine(x + 4, y + 12, x + 7, y + 12); g.drawLine(x + 2, y + 11, x + 3, y + 11); } if (b.isSelected()) { g.setColor(MetalLookAndFeel.getBlack()); g.drawLine(x + 4, y + 3, x + 7, y + 3); g.fillRect(x + 3, y + 4, 6, 4); g.drawLine(x + 4, y + 8, x + 7, y + 8); } g.setColor(savedColor);
public void paintIcon(Component c, Graphics g, int x, int y) { Color dark = MetalLookAndFeel.getControlDarkShadow(); Color light = MetalLookAndFeel.getWhite(); g.translate(x, y); // The light 'circle' g.setColor(light); g.drawLine(4, 1, 10, 1); g.drawLine(2, 2, 3, 2); g.drawLine(8, 2, 11, 2); g.drawLine(2, 3, 2, 3); g.drawLine(11, 2, 11, 9); g.drawLine(1, 4, 1, 7); g.drawLine(12, 4, 12, 7); g.drawLine(2, 8, 2, 11); g.drawLine(11, 8, 11, 9); g.drawLine(10, 10, 10, 10); g.drawLine(2, 11, 9, 11); g.drawLine(4, 12, 7, 12); // The dark 'circle' g.setColor(dark); g.drawLine(4, 0, 7, 0); g.drawLine(2, 1, 3, 1); g.drawLine(8, 1, 9, 1); g.drawLine(1, 2, 1, 3); g.drawLine(10, 2, 10, 3); g.drawLine(0, 4, 0, 7); g.drawLine(11, 4, 11, 7); g.drawLine(1, 8, 1, 9); g.drawLine(10, 8, 10, 9); g.drawLine(2, 10, 3, 10); g.drawLine(8, 10, 9, 10); g.drawLine(4, 11, 7, 11); JRadioButton rb = (JRadioButton) c; if (rb.isSelected()) drawCheck(c, g); g.translate(-x, -y); }
}
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 7, y); g.drawLine(x + 8, y, x + 15, y + 7); g.drawLine(x + 14, y + 8, x + 8, y + 14); g.drawLine(x + 8, y + 14, x + 1, y + 14); g.drawLine(x, y + 13, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 7, 12); g.drawLine(x + 9, y + 2, x + 9, y + 12); g.drawLine(x + 10, y + 3, x + 10, y + 11); g.drawLine(x + 11, y + 4, x + 11, y + 10); g.drawLine(x + 12, y + 5, x + 12, y + 9); g.drawLine(x + 13, y + 6, x + 13, y + 8); g.drawLine(x + 14, y + 7, x + 14, y + 7); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 8, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 13); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 2, y + 10, x + 2, y + 10); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 4, y + 8, x + 4, y + 8); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 6, y + 10, x + 6, y + 10); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 3, y + 11, x + 3, y + 11); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 5, y + 9, x + 5, y + 9); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 7, y + 11, x + 7, y + 11); }
g.setColor(Color.black);
if (enabled) g.setColor(MetalLookAndFeel.getBlack()); else g.setColor(MetalLookAndFeel.getControlDarkShadow());
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 7, y); g.drawLine(x + 8, y, x + 15, y + 7); g.drawLine(x + 14, y + 8, x + 8, y + 14); g.drawLine(x + 8, y + 14, x + 1, y + 14); g.drawLine(x, y + 13, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 7, 12); g.drawLine(x + 9, y + 2, x + 9, y + 12); g.drawLine(x + 10, y + 3, x + 10, y + 11); g.drawLine(x + 11, y + 4, x + 11, y + 10); g.drawLine(x + 12, y + 5, x + 12, y + 9); g.drawLine(x + 13, y + 6, x + 13, y + 8); g.drawLine(x + 14, y + 7, x + 14, y + 7); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 8, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 13); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 2, y + 10, x + 2, y + 10); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 4, y + 8, x + 4, y + 8); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 6, y + 10, x + 6, y + 10); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 3, y + 11, x + 3, y + 11); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 5, y + 9, x + 5, y + 9); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 7, y + 11, x + 7, y + 11); }
g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); g.fillRect(x + 2, y + 2, 7, 12);
if (focus) g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); else g.setColor(MetalLookAndFeel.getControl()); g.fillRect(x + 2, y + 1, 7, 13);
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 7, y); g.drawLine(x + 8, y, x + 15, y + 7); g.drawLine(x + 14, y + 8, x + 8, y + 14); g.drawLine(x + 8, y + 14, x + 1, y + 14); g.drawLine(x, y + 13, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 7, 12); g.drawLine(x + 9, y + 2, x + 9, y + 12); g.drawLine(x + 10, y + 3, x + 10, y + 11); g.drawLine(x + 11, y + 4, x + 11, y + 10); g.drawLine(x + 12, y + 5, x + 12, y + 9); g.drawLine(x + 13, y + 6, x + 13, y + 8); g.drawLine(x + 14, y + 7, x + 14, y + 7); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 8, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 13); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 2, y + 10, x + 2, y + 10); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 4, y + 8, x + 4, y + 8); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 6, y + 10, x + 6, y + 10); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 3, y + 11, x + 3, y + 11); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 5, y + 9, x + 5, y + 9); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 7, y + 11, x + 7, y + 11); }
g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255));
if (focus) g.setColor(MetalLookAndFeel.getPrimaryControl()); else g.setColor(MetalLookAndFeel.getWhite());
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 7, y); g.drawLine(x + 8, y, x + 15, y + 7); g.drawLine(x + 14, y + 8, x + 8, y + 14); g.drawLine(x + 8, y + 14, x + 1, y + 14); g.drawLine(x, y + 13, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 7, 12); g.drawLine(x + 9, y + 2, x + 9, y + 12); g.drawLine(x + 10, y + 3, x + 10, y + 11); g.drawLine(x + 11, y + 4, x + 11, y + 10); g.drawLine(x + 12, y + 5, x + 12, y + 9); g.drawLine(x + 13, y + 6, x + 13, y + 8); g.drawLine(x + 14, y + 7, x + 14, y + 7); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 8, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 13); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 2, y + 10, x + 2, y + 10); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 4, y + 8, x + 4, y + 8); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 6, y + 10, x + 6, y + 10); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 3, y + 11, x + 3, y + 11); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 5, y + 9, x + 5, y + 9); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 7, y + 11, x + 7, y + 11); }
g.setColor(focus ? new Color(102, 102, 153) : Color.black); g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 3, y + 11, x + 3, y + 11); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 5, y + 9, x + 5, y + 9); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 7, y + 11, x + 7, y + 11);
}
public void paintIcon(Component c, Graphics g, int x, int y) { boolean focus = false; if (c != null) focus = c.hasFocus(); // TODO: pick up the colors from the look and feel // draw the outline g.setColor(Color.black); g.drawLine(x + 1, y, x + 7, y); g.drawLine(x + 8, y, x + 15, y + 7); g.drawLine(x + 14, y + 8, x + 8, y + 14); g.drawLine(x + 8, y + 14, x + 1, y + 14); g.drawLine(x, y + 13, x, y + 1); // fill the icon g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium g.fillRect(x + 2, y + 2, 7, 12); g.drawLine(x + 9, y + 2, x + 9, y + 12); g.drawLine(x + 10, y + 3, x + 10, y + 11); g.drawLine(x + 11, y + 4, x + 11, y + 10); g.drawLine(x + 12, y + 5, x + 12, y + 9); g.drawLine(x + 13, y + 6, x + 13, y + 8); g.drawLine(x + 14, y + 7, x + 14, y + 7); // draw highlights g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light g.drawLine(x + 1, y + 1, x + 8, y + 1); g.drawLine(x + 1, y + 2, x + 1, y + 13); g.drawLine(x + 2, y + 2, x + 2, y + 2); g.drawLine(x + 2, y + 6, x + 2, y + 6); g.drawLine(x + 2, y + 10, x + 2, y + 10); g.drawLine(x + 4, y + 4, x + 4, y + 4); g.drawLine(x + 4, y + 8, x + 4, y + 8); g.drawLine(x + 6, y + 2, x + 6, y + 2); g.drawLine(x + 6, y + 6, x + 6, y + 6); g.drawLine(x + 6, y + 10, x + 6, y + 10); // draw dots g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark g.drawLine(x + 3, y + 3, x + 3, y + 3); g.drawLine(x + 3, y + 7, x + 3, y + 7); g.drawLine(x + 3, y + 11, x + 3, y + 11); g.drawLine(x + 5, y + 5, x + 5, y + 5); g.drawLine(x + 5, y + 9, x + 5, y + 9); g.drawLine(x + 7, y + 3, x + 7, y + 3); g.drawLine(x + 7, y + 7, x + 7, y + 7); g.drawLine(x + 7, y + 11, x + 7, y + 11); }
throw new BAD_OPERATION("Invalid enumeration code " + code);
BAD_OPERATION bad = new BAD_OPERATION("Invalid policy code " + code); bad.minor = Minor.PolicyType; throw bad;
public static ServantRetentionPolicyValue from_int(int code) { try { return enume [ code ]; } catch (ArrayIndexOutOfBoundsException ex) { throw new BAD_OPERATION("Invalid enumeration code " + code); } }
if (keys == null) return; for (int i = 0; i < keys.length - 1; i+= 2) { Object key = keys[i]; KeyStroke keyStroke; if (key instanceof KeyStroke) keyStroke = (KeyStroke)key; else keyStroke = KeyStroke.getKeyStroke((String)key); retMap.put(keyStroke, keys[i+1]); }
public static void loadKeyBindings(InputMap retMap, Object[] keys) { // TODO: Implement this properly. }
return null;
ComponentInputMap retMap = new ComponentInputMapUIResource(c); loadKeyBindings(retMap, keys); return retMap;
public static ComponentInputMap makeComponentInputMap(JComponent c, Object[] keys) { return null; }
return null;
InputMap retMap = new InputMapUIResource(); loadKeyBindings(retMap, keys); return retMap;
public static InputMap makeInputMap(Object[] keys) { return null; }
return null;
JTextComponent.KeyBinding[] retBindings = new JTextComponent.KeyBinding[keyBindingList.length / 2]; for (int i = 0; i < keyBindingList.length - 1; i+= 2) { KeyStroke stroke; if (keyBindingList[i] instanceof KeyStroke) stroke = (KeyStroke)keyBindingList[i]; else stroke = KeyStroke.getKeyStroke((String)keyBindingList[i]); retBindings[i/2] = new JTextComponent.KeyBinding(stroke, (String)keyBindingList[i+1]); } return retBindings;
public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList) { return null; }
int origin = mymatch.index; int numRepeats = 0;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
REMatch last = null; REMatch current;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
Vector positions = new Vector(); positions.addElement(newMatch); REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { if ((stingy && (numRepeats >= min)) || alwaysEmpty) {
if (alwaysEmpty) {
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
mymatch.empty = (mymatch.index == origin);
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
if (alwaysEmpty) return false;
return false;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
doables = null; doablesLast = null;
int numRepeats = 0;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { doablesLast.next = recurrent; } while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } if (doables == null) break;
REMatch doables; int lastIndex = mymatch.index; boolean emptyMatchFound = false; while (numRepeats < min) { doables = findDoables(token, input, newMatch); if (doables == null) return false;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
positions.addElement(newMatch);
if (newMatch.empty) { numRepeats = min; emptyMatchFound = true; break; } lastIndex = newMatch.index; } Vector positions = new Vector(); while (numRepeats <= max) { if (stopMatchingIfSatisfied && stingy) { REMatch results = matchRest(input, newMatch); if (results != null) { mymatch.assignFrom(results); return true; } } positions.add(newMatch); if (emptyMatchFound) break; doables = findDoables(token, input, newMatch); if (doables == null) break;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
if (numRepeats < min) numRepeats = min; break;
emptyMatchFound = true;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
if (numRepeats > min) { numRepeats--; positions.remove(positions.size() - 1); break;
if (!stingy) break;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
if (numRepeats == min) break;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
lastIndex = doables.index; } while (numRepeats < max);
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
if (numRepeats < min) return false; int posIndex = positions.size();
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
REMatch allResults = null; REMatch allResultsLast = null;
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch);
REMatch.REMatchList allResults = new REMatch.REMatchList(); int posCount = positions.size(); int posIndex = (stingy ? 0 : posCount - 1); while (posCount-- > 0) { REMatch m = (REMatch) positions.elementAt(posIndex); if (stingy) posIndex++; else posIndex--; REMatch results = matchRest(input, m);
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
if (allResults == null) { allResults = results; allResultsLast = results; } else {
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
allResultsLast.next = results;
allResults.addTail(results);
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } }
else {
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
if (allResults != null) { mymatch.assignFrom(allResults); mymatch.empty = (mymatch.index == origin);
} if (allResults.head != null) { mymatch.assignFrom(allResults.head);
boolean match(CharIndexed input, REMatch mymatch) { int origin = mymatch.index; // number of times we've matched so far int numRepeats = 0; // Possible positions for the next repeat to match at REMatch newMatch = mymatch; REMatch last = null; REMatch current; // Add the '0-repeats' index // positions.elementAt(z) == position [] in input after <<z>> matches Vector positions = new Vector(); positions.addElement(newMatch); // Declare variables used in loop REMatch doables; REMatch doablesLast; REMatch recurrent; int lastIndex = mymatch.index; do { // Check for stingy match for each possibility. if ((stingy && (numRepeats >= min)) || alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result); mymatch.empty = (mymatch.index == origin); return true; } else { // Special case of {0}. It must always match an empty string. if (alwaysEmpty) return false; } } doables = null; doablesLast = null; // try next repeat at all possible positions for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } } // if none of the possibilities worked out, break out of do/while if (doables == null) break; // reassign where the next repeat can match newMatch = doables; // increment how many repeats we've successfully found ++numRepeats; positions.addElement(newMatch); // doables.index == lastIndex occurs either // (1) when an empty string was the longest // that matched this token. // And this case occurs either // (1-1) when this token is always empty, // for example "()" or "(())". // (1-2) when this token is not always empty // but can match an empty string, for example, // "a*", "(a|)". // or // (2) when the same string matches this token many times. // For example, "acbab" itself matches "a.*b" and // its substrings "acb" and "ab" also match. if (doables.index == lastIndex) { if (doables.empty) { // Case (1): We break here, otherwise we will fall // into an endless loop. if (numRepeats < min) numRepeats = min; break; } else { // Case (2): We cannot break here because, for example, // "acbacb" matches "a.*b" up to 2 times but // not 3 times. So we have to check numRepeats >= min. // But we do not have to go further until numRepeats == max // because the more numRepeats grows, the shorter the // substring matching this token becomes. if (numRepeats > min) { // This means the previous match was successful, // and that must be the best match. This match // resulted in shortening the matched substring. numRepeats--; positions.remove(positions.size() - 1); break; } if (numRepeats == min) break; } } lastIndex = doables.index; } while (numRepeats < max); // If there aren't enough repeats, then fail if (numRepeats < min) return false; // We're greedy, but ease off until a true match is found int posIndex = positions.size(); // At this point we've either got too many or just the right amount. // See if this numRepeats works with the rest of the regexp. REMatch allResults = null; REMatch allResultsLast = null; REMatch results = null; int indexCount = posIndex - min; if (indexCount <= 0) { // This case occurs when we exited the previous do loop before // numRepeats >= min because an empty string matched the token. // In this case, an empty string can match as many times as // desired. indexCount = 1; } while (indexCount-- > 0) { --posIndex; newMatch = (REMatch) positions.elementAt(posIndex); results = matchRest(input, newMatch); if (results != null) { if (allResults == null) { allResults = results; allResultsLast = results; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) allResultsLast.next = results; } // Find new doablesLast while (allResultsLast.next != null) { allResultsLast = allResultsLast.next; } } // else did not match rest of the tokens, try again on smaller sample // or break out when performing possessive matching if (possessive) break; } if (allResults != null) { mymatch.assignFrom(allResults); // does this get all? mymatch.empty = (mymatch.index == origin); return true; } // If we fall out, no matches. return false; }
REMatch doneIndex = null; REMatch doneIndexLast = null;
REMatch.REMatchList doneIndex = new REMatch.REMatchList();
private REMatch matchRest(CharIndexed input, final REMatch newMatch) { REMatch current, single; REMatch doneIndex = null; REMatch doneIndexLast = null; // Test all possible matches for this number of repeats for (current = newMatch; current != null; current = current.next) { // clone() separates a single match from the chain single = (REMatch) current.clone(); if (next(input, single)) { // chain results to doneIndex if (doneIndex == null) { doneIndex = single; doneIndexLast = single; } else { doneIndexLast.next = single; } // Find new doneIndexLast while (doneIndexLast.next != null) { doneIndexLast = doneIndexLast.next; } } } return doneIndex; }
if (doneIndex == null) { doneIndex = single; doneIndexLast = single; } else { doneIndexLast.next = single; } while (doneIndexLast.next != null) { doneIndexLast = doneIndexLast.next; }
doneIndex.addTail(single);
private REMatch matchRest(CharIndexed input, final REMatch newMatch) { REMatch current, single; REMatch doneIndex = null; REMatch doneIndexLast = null; // Test all possible matches for this number of repeats for (current = newMatch; current != null; current = current.next) { // clone() separates a single match from the chain single = (REMatch) current.clone(); if (next(input, single)) { // chain results to doneIndex if (doneIndex == null) { doneIndex = single; doneIndexLast = single; } else { doneIndexLast.next = single; } // Find new doneIndexLast while (doneIndexLast.next != null) { doneIndexLast = doneIndexLast.next; } } } return doneIndex; }
return doneIndex;
return doneIndex.head;
private REMatch matchRest(CharIndexed input, final REMatch newMatch) { REMatch current, single; REMatch doneIndex = null; REMatch doneIndexLast = null; // Test all possible matches for this number of repeats for (current = newMatch; current != null; current = current.next) { // clone() separates a single match from the chain single = (REMatch) current.clone(); if (next(input, single)) { // chain results to doneIndex if (doneIndex == null) { doneIndex = single; doneIndexLast = single; } else { doneIndexLast.next = single; } // Find new doneIndexLast while (doneIndexLast.next != null) { doneIndexLast = doneIndexLast.next; } } } return doneIndex; }
static Frame getOwnerFrame()
static Window getOwnerFrame(Window owner) { Window result = owner; if (result == null)
static Frame getOwnerFrame() { if (ownerFrame == null) ownerFrame = new OwnerFrame(); return ownerFrame; }
return ownerFrame;
result = ownerFrame; } return result;
static Frame getOwnerFrame() { if (ownerFrame == null) ownerFrame = new OwnerFrame(); return ownerFrame; }
synchronized(data) { byte[] newData = new byte[getRecLen()]; System.arraycopy(data, offset, newData, 0, getRecLen()); this.data = newData; setOffset(0); }
public Ext2DirectoryRecord(Ext2FileSystem fs, byte[] data, int offset, int fileOffset) { this.fs=fs; this.data = data; this.offset = offset; this.fileOffset = fileOffset; //make a copy of the data /* byte[] newData = new byte[getRecLen()]; System.arraycopy(data, offset, newData, 0, getRecLen()); this.data = newData; setOffset(0); */ }
protected void expandRecord(long beginning, long end) throws FileSystemException{
protected synchronized void expandRecord(long beginning, long end) throws FileSystemException{
protected void expandRecord(long beginning, long end) throws FileSystemException{ log.debug("expandRecord("+beginning + ", "+ end+")"); if(beginning+getNameLen()+8 < end) { //the record fits in the block setRecLen((int)(end - beginning)); //pad the end of the record with zeroes byte[] newData = new byte[getRecLen()]; Arrays.fill(newData, 0, getRecLen(), (byte)0); System.arraycopy(data, getOffset(), newData, 0, getNameLen()+8); setOffset(0); setFileOffset(beginning); data=newData; } else throw new FileSystemException("The directory record does not fit into the block!"); log.debug("expandRecord(): newLength: "+getRecLen()); }
public int getINodeNr() {
public synchronized int getINodeNr() {
public int getINodeNr() { return (int)Ext2Utils.get32(data, offset); }
public String getName() {
public synchronized String getName() {
public String getName() { StringBuffer name = new StringBuffer(); if(getINodeNr()!=0) { //TODO: character conversion?? for(int i=0; i<getNameLen(); i++) name.append( (char)Ext2Utils.get8(data, offset+8+i) ); log.debug("Ext2DirectoryRecord(): iNode="+getINodeNr()+", name="+name); } return name.toString(); }
private int getNameLen() {
private synchronized int getNameLen() {
private int getNameLen() { return Ext2Utils.get8(data, offset+6); }
public int getRecLen() {
public synchronized int getRecLen() {
public int getRecLen() { return Ext2Utils.get16(data, offset+4); }
public int getType() {
public synchronized int getType() {
public int getType() { return Ext2Utils.get8(data, offset+7); }
private void setINodeNr(long nr) {
private synchronized void setINodeNr(long nr) {
private void setINodeNr(long nr) { Ext2Utils.set32(data, offset, nr); }
private void setName(String name) {
private synchronized void setName(String name) {
private void setName(String name) { for(int i=0; i<name.length(); i++) Ext2Utils.set8(data, offset+8+i, name.charAt(i)); }
private void setNameLen(int len) {
private synchronized void setNameLen(int len) {
private void setNameLen(int len) { Ext2Utils.set8(data, offset+6, len); }
private void setRecLen(int len) {
private synchronized void setRecLen(int len) {
private void setRecLen(int len) { Ext2Utils.set16(data, offset+4, len); }
private void setType(int type) {
private synchronized void setType(int type) {
private void setType(int type) { if(!fs.hasIncompatFeature(Ext2Constants.EXT2_FEATURE_INCOMPAT_FILETYPE)) return; Ext2Utils.set8(data, offset+7, type); }
protected void truncateRecord() {
protected synchronized void truncateRecord() {
protected void truncateRecord() { int newLength = getNameLen() + 8; //record length is padded to n*4 bytes if(newLength%4!=0) newLength+=4-newLength%4; setRecLen(newLength); log.debug("truncateRecord(): newLength: "+newLength); }
if (cp.equals("870-sk")) return codePage870sk;
public static final int[] getCodePage(String cp) { if (cp.equals("37")) return codePage37; if (cp.equals("37PT")) return codePage37PT; if (cp.equals("273")) return codePage273; if (cp.equals("277-dk")) return codePage277_DK; if (cp.equals("277-no")) return codePage277_NO; if (cp.equals("280")) return codePage280; if (cp.equals("284")) return codePage284; if (cp.equals("285")) return codePage285; if (cp.equals("297")) return codePage297; if (cp.equals("424")) return codePage500ch; if (cp.equals("500-ch")) return codePage500ch; if (cp.equals("870-pl")) return codePage870; if (cp.equals("1025-r")) return codePage1025; return codePage37; }
if (e.getPropertyName().equals(JToolBar.ROLLOVER_CHANGED_PROPERTY))
if (e.getPropertyName().equals("rollover"))
public void propertyChange(PropertyChangeEvent e) { // FIXME: need name properties so can change floatFrame title. if (e.getPropertyName().equals(JToolBar.ROLLOVER_CHANGED_PROPERTY)) setRolloverBorders(toolBar.isRollover()); }
nestedToXDF(outputstream, indent, 0, stop);
synchronized (attribHash) { nestedToXDF(outputstream, indent, 0, stop); }
protected void specificIOStyleToXDF( OutputStream outputstream,String indent) { int stop = parentArray.getAxisList().size()-1; nestedToXDF(outputstream, indent, 0, stop); }
d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap;
d.width += checkIcon.getIconWidth() + defaultTextIconGap;
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width += rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) // It is a MenuItem d.width += arrowIcon.getIconWidth() + m.getParent().getWidth(); else // It is a Menu, no arrowIcon painted. d.width += MenuGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
if (!((JMenu) c).isTopLevelMenu()) d.width += arrowIcon.getIconWidth() + m.getParent().getWidth();
int pWidth = m.getParent().getWidth(); if (!((JMenu)c).isTopLevelMenu() && d.width < pWidth) d.width = pWidth - m.getInsets().left - m.getInsets().right;
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width += rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) // It is a MenuItem d.width += arrowIcon.getIconWidth() + m.getParent().getWidth(); else // It is a Menu, no arrowIcon painted. d.width += MenuGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
d.width += MenuGap;
d.width += arrowIcon.getIconWidth() + MenuGap;
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect( accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width += rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { if (!((JMenu) c).isTopLevelMenu()) // It is a MenuItem d.width += arrowIcon.getIconWidth() + m.getParent().getWidth(); else // It is a Menu, no arrowIcon painted. d.width += MenuGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
public AccessibleJDialog()
protected AccessibleJDialog()
public AccessibleJDialog() { super(); // Nothing to do here. }
super(toolkit, list, new JList()); this.list = list;
super(toolkit, list, new SwingList(list));
public SwingListPeer(SwingToolkit toolkit, final List list) { super(toolkit, list, new JList()); this.list = list; final JList jList = (JList)jComponent; SwingToolkit.add(list, jList); SwingToolkit.copyAwtProperties(list, jList); final ListModel model = new AbstractListModel() { public Object getElementAt(int idx) { return list.getItem(idx); } public int getSize() { return list.getItemCount(); } }; }
classXDFNodeName = super.getClassXDFNodeName()+ "||" + "string";
parentClassXDFNodeName = super.getClassXDFNodeName(); classXDFNodeName = "string";
private void init() { classXDFNodeName = super.getClassXDFNodeName()+ "||" + "string"; attribOrder.add(0, "length"); //add length as the first attribute; attribHash.put("lessThanValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("lessThanOrEqualValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("greaterThanValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("greaterThanOrEqualValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("infiniteValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("infiniteNegativeValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("noDataValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("length", new XMLAttribute(new Integer(0), Constants.NUMBER_TYPE)); }
frame.show();
frame.setVisible(true);
public void run() { frame.show(); }
if (mark == s.count)
if (mark >= s.count)
public static final int getBreakLocation(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset) { int mark = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset); BreakIterator breaker = BreakIterator.getWordInstance(); breaker.setText(s); // If mark is equal to the end of the string, just use that position if (mark == s.count) return mark; // Try to find a word boundary previous to the mark at which we // can break the text int preceding = breaker.preceding(mark + 1); if (preceding != 0) return preceding; else // If preceding is 0 we couldn't find a suitable word-boundary so // just break it on the character boundary return mark; }
if (isEncodingAvailable("1141")) {
if (isEncodingAvailable("Cp1141")) {
static final CodePage getCodePage(String cp) { System.err.println("Trying NativeCodePage:" + cp); if (cp.equals("37")) return new NativeCodePage(cp, codePage37); if (cp.equals("37PT")) return new NativeCodePage(cp, codePage37PT); if (cp.equals("273")) return new NativeCodePage(cp, codePage273); if (cp.equals("277-dk")) return new NativeCodePage(cp, codePage277_DK); if (cp.equals("277-no")) return new NativeCodePage(cp, codePage277_NO); if (cp.equals("278")) return new NativeCodePage(cp, codePage278); if (cp.equals("280")) return new NativeCodePage(cp, codePage280); if (cp.equals("284")) return new NativeCodePage(cp, codePage284); if (cp.equals("285")) return new NativeCodePage(cp, codePage285); if (cp.equals("297")) return new NativeCodePage(cp, codePage297); if (cp.equals("424")) return new NativeCodePage(cp, codePage500ch); if (cp.equals("500-ch")) return new NativeCodePage(cp, codePage500ch); if (cp.equals("870-pl")) return new NativeCodePage(cp, codePage870); if (cp.equals("870-sk")) return new NativeCodePage(cp, codePage870sk); if (cp.equals("871")) return new NativeCodePage(cp, codePage871); if (cp.equals("875")) return new NativeCodePage(cp, codePage875); if (cp.equals("1025-r")) return new NativeCodePage(cp, codePage1025); if (cp.equals("1026")) return new NativeCodePage(cp, codePage1026); if (cp.equals("1141")) { if (isEncodingAvailable("1141")) { return new NativeCodePage(cp, codePage1141); } else { System.err.println("Charset encoding 1141 not available"); return null; } } if (cp.equals("1140")) { if (isEncodingAvailable("1140")) { return new NativeCodePage(cp, codePage1140); } else { System.err.println("Charset encoding 1140 not available"); return null; } } if (cp.equals("1147")) return new NativeCodePage(cp, codePage1147);// return codePage37; return null; }
if (isEncodingAvailable("1140")) {
if (isEncodingAvailable("Cp1140")) {
static final CodePage getCodePage(String cp) { System.err.println("Trying NativeCodePage:" + cp); if (cp.equals("37")) return new NativeCodePage(cp, codePage37); if (cp.equals("37PT")) return new NativeCodePage(cp, codePage37PT); if (cp.equals("273")) return new NativeCodePage(cp, codePage273); if (cp.equals("277-dk")) return new NativeCodePage(cp, codePage277_DK); if (cp.equals("277-no")) return new NativeCodePage(cp, codePage277_NO); if (cp.equals("278")) return new NativeCodePage(cp, codePage278); if (cp.equals("280")) return new NativeCodePage(cp, codePage280); if (cp.equals("284")) return new NativeCodePage(cp, codePage284); if (cp.equals("285")) return new NativeCodePage(cp, codePage285); if (cp.equals("297")) return new NativeCodePage(cp, codePage297); if (cp.equals("424")) return new NativeCodePage(cp, codePage500ch); if (cp.equals("500-ch")) return new NativeCodePage(cp, codePage500ch); if (cp.equals("870-pl")) return new NativeCodePage(cp, codePage870); if (cp.equals("870-sk")) return new NativeCodePage(cp, codePage870sk); if (cp.equals("871")) return new NativeCodePage(cp, codePage871); if (cp.equals("875")) return new NativeCodePage(cp, codePage875); if (cp.equals("1025-r")) return new NativeCodePage(cp, codePage1025); if (cp.equals("1026")) return new NativeCodePage(cp, codePage1026); if (cp.equals("1141")) { if (isEncodingAvailable("1141")) { return new NativeCodePage(cp, codePage1141); } else { System.err.println("Charset encoding 1141 not available"); return null; } } if (cp.equals("1140")) { if (isEncodingAvailable("1140")) { return new NativeCodePage(cp, codePage1140); } else { System.err.println("Charset encoding 1140 not available"); return null; } } if (cp.equals("1147")) return new NativeCodePage(cp, codePage1147);// return codePage37; return null; }
public void propertyChange(PropertyChangeEvent evt)
public void propertyChange(PropertyChangeEvent e)
public void propertyChange(PropertyChangeEvent evt) { }
throw new LinkageError("Failed to compile " + name, ex);
final LinkageError le = new LinkageError("Failed to compile " + name); le.initCause(ex); throw le;
private synchronized void doCompile() { if (isCompiled()) { return; } if (!isCompiling()) { if (loader.isCompileRequired()) { state |= VmTypeState.ST_COMPILING; //BootLog.debug("Compiling " + getName()); // Compile the superclass (if any) if (superClass != null) { superClass.compile(); } // Compile the methods with the least optimizing compiler final int count; try { count = doCompileRuntime(0); } catch (Throwable ex) { state |= VmTypeState.ST_INVALID; state &= ~VmTypeState.ST_COMPILING; errorMsg = ex.toString(); throw new LinkageError("Failed to compile " + name, ex); } final int declared = getNoDeclaredMethods(); if (count != declared) { errorMsg = "Compiled skipped some methods (" + (declared - count); throw new LinkageError(errorMsg); } state &= ~VmTypeState.ST_COMPILING; notifyAll(); } } }
setOpaque(true);
setOpaque(false);
public Component getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (leaf) setIcon(getLeafIcon()); else if (expanded) setIcon(getOpenIcon()); else setIcon(getClosedIcon()); setText(val.toString()); this.selected = selected; this.hasFocus = hasFocus; setHorizontalAlignment(LEFT); setOpaque(true); setVerticalAlignment(TOP); setEnabled(true); super.setFont(UIManager.getLookAndFeelDefaults().getFont("Tree.font")); if (selected) { super.setBackground(getBackgroundSelectionColor()); setForeground(getTextSelectionColor()); } else { super.setBackground(getBackgroundNonSelectionColor()); setForeground(getTextNonSelectionColor()); } return this; }
setBorder(UIManager.getLookAndFeelDefaults().getBorder("Tree.nonSelectionBorder"));
public Component getTreeCellRendererComponent(JTree tree, Object val, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (leaf) setIcon(getLeafIcon()); else if (expanded) setIcon(getOpenIcon()); else setIcon(getClosedIcon()); setText(val.toString()); this.selected = selected; this.hasFocus = hasFocus; setHorizontalAlignment(LEFT); setOpaque(true); setVerticalAlignment(TOP); setEnabled(true); super.setFont(UIManager.getLookAndFeelDefaults().getFont("Tree.font")); if (selected) { super.setBackground(getBackgroundSelectionColor()); setForeground(getTextSelectionColor()); } else { super.setBackground(getBackgroundNonSelectionColor()); setForeground(getTextNonSelectionColor()); } return this; }
if (descriptor) { switch (type_code.charAt(0)) { case 'B': return byte.class; case 'C': return char.class; case 'D': return double.class; case 'F': return float.class; case 'I': return int.class; case 'J': return long.class; case 'S': return short.class; case 'V': return void.class; case 'Z': return boolean.class; default: throw new ClassNotFoundException("Invalid class name: " + type_code); case 'L': type_code = type_code.substring(1, type_code.length() - 1); case '[': } } return Class.forName(type_code.replace('/', '.'));
return getClassForEncoding(type_code, descriptor, null);
public static Class getClassForEncoding(String type_code, boolean descriptor) throws ClassNotFoundException { if (descriptor) { switch (type_code.charAt(0)) { case 'B': return byte.class; case 'C': return char.class; case 'D': return double.class; case 'F': return float.class; case 'I': return int.class; case 'J': return long.class; case 'S': return short.class; case 'V': return void.class; case 'Z': return boolean.class; default: throw new ClassNotFoundException("Invalid class name: " + type_code); case 'L': type_code = type_code.substring(1, type_code.length() - 1); // Fallthrough. case '[': } } return Class.forName(type_code.replace('/', '.')); }
if (CurrentArray.getDataCube().getHref() != null) return;
if ( !(formatObj instanceof DelimitedXMLDataIOStyle) && CurrentArray.getDataCube().getHref() != null) return;
public void action (SaxDocumentHandler handler) throws SAXException { // we stopped reading datanode, lower count by one DataNodeLevel--; // we might still be nested within a data node // if so, return now to accumulate more data within the DATABLOCK if(DataNodeLevel != 0) return; // only add the data here if it was *not* read in from a file if (CurrentArray.getDataCube().getHref() != null) return; // now we are ready to read in untagged data (both delimited/formmatted styles) // from the DATABLOCK // Note: unfortunately we are reduced to using regex style matching // instead of a buffer read in formatted reads. Come back and // improve this later if possible. XMLDataIOStyle formatObj = CurrentArray.getXMLDataIOStyle(); if ( formatObj instanceof DelimitedXMLDataIOStyle || formatObj instanceof FormattedXMLDataIOStyle ) { FieldAxis fieldAxis = null; boolean hasFieldAxis = false; // determine the size of the dataFormat (s) in our dataCube if (CurrentArray.hasFieldAxis()) { // if there is a field axis, then its set to the number of fields fieldAxis = CurrentArray.getFieldAxis(); MaxDataFormatIndex = (fieldAxis.getLength()-1); hasFieldAxis = true; } else { // its homogeneous MaxDataFormatIndex = 0; } Locator myLocator = CurrentArray.createLocator(); // myLocator.setIterationOrder(AxisReadOrder); // shouldnt be needed now, havent checked tho CurrentDataFormatIndex = 0; ArrayList strValueList; // set up appropriate instructions for reading if ( formatObj instanceof FormattedXMLDataIOStyle ) { // snag the string representation of the values strValueList = formattedSplitStringIntoStringObjects( DATABLOCK.toString(), ((FormattedXMLDataIOStyle) formatObj) ); if (strValueList.size() == 0) { Log.errorln("Error: XDF Reader is unable to acquire formatted data, bad format?"); System.exit(-1); } } else { // Delimited Case here // snag the string representation of the values strValueList = splitStringIntoStringObjects( DATABLOCK.toString(), ((DelimitedXMLDataIOStyle) formatObj).getDelimiter(), ((DelimitedXMLDataIOStyle) formatObj).getRepeatable(), ((DelimitedXMLDataIOStyle) formatObj).getRecordTerminator() ); } // fire data into dataCube Iterator iter = strValueList.iterator(); while (iter.hasNext()) { DataFormat CurrentDataFormat = DataFormatList[CurrentDataFormatIndex]; // adding data based on what type.. String thisData = (String) iter.next(); try { addDataToCurrentArray(myLocator, thisData, CurrentDataFormat, IntRadix[CurrentDataFormatIndex]); } catch (SetDataException e) { // bizarre error. Cant add data (out of memory??) :P Log.errorln("Unable to setData:["+thisData+"], ignoring request"); // Log.printStackTrace(e); throw new SAXException(e.getMessage()); } myLocator.next(); // bump up DataFormat appropriately if (hasFieldAxis) { int currentFieldAxisCoordinate = myLocator.getAxisIndex(fieldAxis); if ( currentFieldAxisCoordinate != LastFieldAxisCoordinate ) { LastFieldAxisCoordinate = currentFieldAxisCoordinate; if (CurrentDataFormatIndex == MaxDataFormatIndex) CurrentDataFormatIndex = 0; else CurrentDataFormatIndex++; } } } } else if ( formatObj instanceof TaggedXMLDataIOStyle ) { // Tagged case: do nothing } else { Log.errorln("ERROR: Completely unknown DATA IO style:"+formatObj.toString() +" aborting read!"); System.exit(-1); } }
XMLDataIOStyle formatObj = CurrentArray.getXMLDataIOStyle();
public void action (SaxDocumentHandler handler) throws SAXException { // we stopped reading datanode, lower count by one DataNodeLevel--; // we might still be nested within a data node // if so, return now to accumulate more data within the DATABLOCK if(DataNodeLevel != 0) return; // only add the data here if it was *not* read in from a file if (CurrentArray.getDataCube().getHref() != null) return; // now we are ready to read in untagged data (both delimited/formmatted styles) // from the DATABLOCK // Note: unfortunately we are reduced to using regex style matching // instead of a buffer read in formatted reads. Come back and // improve this later if possible. XMLDataIOStyle formatObj = CurrentArray.getXMLDataIOStyle(); if ( formatObj instanceof DelimitedXMLDataIOStyle || formatObj instanceof FormattedXMLDataIOStyle ) { FieldAxis fieldAxis = null; boolean hasFieldAxis = false; // determine the size of the dataFormat (s) in our dataCube if (CurrentArray.hasFieldAxis()) { // if there is a field axis, then its set to the number of fields fieldAxis = CurrentArray.getFieldAxis(); MaxDataFormatIndex = (fieldAxis.getLength()-1); hasFieldAxis = true; } else { // its homogeneous MaxDataFormatIndex = 0; } Locator myLocator = CurrentArray.createLocator(); // myLocator.setIterationOrder(AxisReadOrder); // shouldnt be needed now, havent checked tho CurrentDataFormatIndex = 0; ArrayList strValueList; // set up appropriate instructions for reading if ( formatObj instanceof FormattedXMLDataIOStyle ) { // snag the string representation of the values strValueList = formattedSplitStringIntoStringObjects( DATABLOCK.toString(), ((FormattedXMLDataIOStyle) formatObj) ); if (strValueList.size() == 0) { Log.errorln("Error: XDF Reader is unable to acquire formatted data, bad format?"); System.exit(-1); } } else { // Delimited Case here // snag the string representation of the values strValueList = splitStringIntoStringObjects( DATABLOCK.toString(), ((DelimitedXMLDataIOStyle) formatObj).getDelimiter(), ((DelimitedXMLDataIOStyle) formatObj).getRepeatable(), ((DelimitedXMLDataIOStyle) formatObj).getRecordTerminator() ); } // fire data into dataCube Iterator iter = strValueList.iterator(); while (iter.hasNext()) { DataFormat CurrentDataFormat = DataFormatList[CurrentDataFormatIndex]; // adding data based on what type.. String thisData = (String) iter.next(); try { addDataToCurrentArray(myLocator, thisData, CurrentDataFormat, IntRadix[CurrentDataFormatIndex]); } catch (SetDataException e) { // bizarre error. Cant add data (out of memory??) :P Log.errorln("Unable to setData:["+thisData+"], ignoring request"); // Log.printStackTrace(e); throw new SAXException(e.getMessage()); } myLocator.next(); // bump up DataFormat appropriately if (hasFieldAxis) { int currentFieldAxisCoordinate = myLocator.getAxisIndex(fieldAxis); if ( currentFieldAxisCoordinate != LastFieldAxisCoordinate ) { LastFieldAxisCoordinate = currentFieldAxisCoordinate; if (CurrentDataFormatIndex == MaxDataFormatIndex) CurrentDataFormatIndex = 0; else CurrentDataFormatIndex++; } } } } else if ( formatObj instanceof TaggedXMLDataIOStyle ) { // Tagged case: do nothing } else { Log.errorln("ERROR: Completely unknown DATA IO style:"+formatObj.toString() +" aborting read!"); System.exit(-1); } }
thisString = thisString.trim();
private void addDataToCurrentArray ( Locator dataLocator, String thisString, DataFormat CurrentDataFormat, int intRadix ) throws SetDataException {// this stuff slows down the parser too much to leave commented in.// uncomment as needed/*Log.info("Add Data:["+thisString+"] (");List axes = dataLocator.getIterationOrder();Iterator liter = axes.iterator();while (liter.hasNext()) { AxisInterface axis = (AxisInterface) liter.next(); Log.info(dataLocator.getAxisIndex(axis)+ " ["+axis.getAxisId()+"],");}Log.infoln(") ["+CurrentDataFormat+"]");*/ // Note that we dont treat binary data at all here // try { if ( CurrentDataFormat instanceof StringDataFormat) { CurrentArray.setData(dataLocator, thisString); } else if ( CurrentDataFormat instanceof FloatDataFormat || CurrentDataFormat instanceof BinaryFloatDataFormat) { Double number = new Double (thisString); CurrentArray.setData(dataLocator, number.doubleValue()); } else if ( CurrentDataFormat instanceof IntegerDataFormat || CurrentDataFormat instanceof BinaryIntegerDataFormat) { // Integer number = new Integer (thisString); if (intRadix == 16) // peal off leading "0x" thisString = thisString.substring(2); int thisInt = 0; // *sigh* parseInt doesnt understand leading "+" signs. We need // to trap those errors an deal with them appropriately try { thisInt = Integer.parseInt(thisString, intRadix); } catch (NumberFormatException e) { if (thisString.startsWith("+")) { thisInt = Integer.parseInt(thisString.substring(1), intRadix); } else { throw e; } } CurrentArray.setData(dataLocator, thisInt); } else { Log.warnln("Unknown data format, unable to setData:["+thisString+"], ignoring request"); }/* } catch (SetDataException e) { // bizarre error. Cant add data (out of memory??) :P Log.errorln("Unable to setData:["+thisString+"], ignoring request"); Log.printStackTrace(e); }*/ }
else if (readObj instanceof DelimitedXMLDataIOStyle) { String data = getCharacterDataFromInputStream(in); if (!IgnoreWhitespaceOnlyData || stringIsNotAllWhitespace(data) ) { DATABLOCK.append(data); } }
private void loadHrefDataIntoCurrentArray ( Entity hrefObj, XMLDataIOStyle readObj, String compressionType ) throws SAXException { // well, we should be doing something with base here, // but arent because it isnt captured by this API. feh. // $file = $href->getBase() if $href->getBase(); if (hrefObj.getSystemId() != null) { try { InputStream in = null; try { InputSource inputSource = resolveEntity(hrefObj.getPublicId(), hrefObj.getSystemId()); in = inputSource.getByteStream(); } catch (SAXException e) { Log.printStackTrace(e); } catch (NullPointerException e) { // in this case the InputSource object is null to request that // the parser open a regular URI connection to the system identifier. // In our case, the systemId IS the filename. // File f = new File(hrefObj.getSystemId()); // in = (InputStream) new BufferedInputStream (new FileInputStream(new File(hrefObj.getSystemId()))); try { in = getInputStreamFromHref(hrefObj, compressionType); } catch (IOException ex) { Log.printStackTrace(ex); } } if (in != null) { in = (InputStream) new BufferedInputStream (in); if (readObj instanceof FormattedXMLDataIOStyle) { // probably could treat endian as a global too, since thats // how we treat the rest of the array parameters Locator locator = CurrentArray.createLocator(); String endian = readObj.getEndian(); readFormattedInputStreamIntoArray(in, locator, endian); } else if (readObj instanceof TaggedXMLDataIOStyle) { readTaggedInputStreamIntoArray(in); } else { throw new SAXException("Cant load external data of XMLDataIOStyle type:"+readObj.getClass()); } } } catch (java.io.IOException e) { Log.printStackTrace(e); } } else { Log.warnln("Can't read Entity data, undefined systemId!"); } }
Log.debugln("Got Delimited DataCell ("+start+","+termend+") (repeatable):["+valueString+"]");
private ArrayList splitStringIntoStringObjects ( String valueListString, String delimiter, String repeatable, String terminatingDelimiter ) { // the list we will return ArrayList values = new ArrayList(); // parameters int delimiterSize = delimiter.length(); char delimitChar0 = delimiter.charAt(0); int termDelimiterSize = 0; char termDelimitChar0; int valueListSize = valueListString.length(); boolean isNotRepeatable = repeatable.equals("yes") ? false : true; if(terminatingDelimiter != null) { termDelimiterSize = terminatingDelimiter.length(); termDelimitChar0 = terminatingDelimiter.charAt(0); } // loop over the valueListString and derive values int start = 0; while ( start < valueListSize ) { int stop = start + delimiterSize; // safety, can happen if(stop > valueListSize) stop = valueListSize; if ( valueListString.substring(start, stop).compareTo(delimiter) == 0 ) { // we hit a delimiter start += delimiterSize; if (isNotRepeatable) { // gather a value now. // find the end of this substring int end = valueListString.indexOf(delimitChar0, start); int termend = 0; if(terminatingDelimiter != null) termend = valueListString.indexOf(terminatingDelimiter.charAt(0), start); String valueString; if(termend == 0 || end < termend) { // can happen if no terminating delimiter if (end < 0) end = valueListSize; // derive our value from string valueString = valueListString.substring(start, end); // add the value to arrayList values.add(valueString); // this is the last value so terminate the while loop if ((end+delimiterSize) >= valueListSize ) break; start = end; } else { // if (termend < 0) termend = valueListSize; valueString = valueListString.substring(start, termend); // add the value to arrayList values.add(valueString); // this is the last value so terminate the while loop if ((termend+termDelimiterSize) >= valueListSize ) break; start = termend; } } } else if (termDelimiterSize > 0 && valueListString.substring(start, start + termDelimiterSize).compareTo(terminatingDelimiter) == 0 ) { // we hit record terminator(delimiter) start += termDelimiterSize; // we DONT repeat on record terminators (??)/* if (isNotRepeatable) { // gather values now.Log.errorln("ISNOTREPEATABLE CHECK"); // find the end of this substring int end = valueListString.indexOf(delimitChar0, start); int termend = 0; if(terminatingDelimiter != null) termend = valueListString.indexOf(terminatingDelimiter.charAt(0), start);Log.error("end:"+end+" termend:"+termend); String valueString; if(termend == 0 || end < termend) { // can happen if no terminating delimiter if (end < 0) end = valueListSize; // derive our value from string valueString = valueListString.substring(start, end); // add the value to arrayList values.add(valueString);Log.errorln(" DValue:"+valueString); // this is the last value so terminate the while loop if ((end+delimiterSize) >= valueListSize ) break; start = end; } else { // if (termend < 0) termend = valueListSize; valueString = valueListString.substring(start, termend); // add the value to arrayList values.add(valueString);Log.errorln(" TValue:"+valueString); // this is the last value so terminate the while loop if ((termend+termDelimiterSize) >= valueListSize ) break; start = termend; }*/ } else { // we didnt hit a delimiter, gather values // find the end of this substring int end = valueListString.indexOf(delimitChar0, start); int termend = 0; if(terminatingDelimiter != null) termend = valueListString.indexOf(terminatingDelimiter.charAt(0), start); String valueString; if(termend == 0 || end < termend) { // can happen if no terminating delimiter if (end < 0) end = valueListSize; // derive our value from string valueString = valueListString.substring(start, end); // add the value to arrayList values.add(valueString); // this is the last value so terminate the while loop if ((end+delimiterSize) >= valueListSize ) break; start = end; } else { // if (termend < 0) termend = valueListSize; valueString = valueListString.substring(start, termend); // add the value to arrayList values.add(valueString); // this is the last value so terminate the while loop if ((termend+termDelimiterSize) >= valueListSize ) break; start = termend; } } } return values; }
this.scale = font.getSize() / fontData.getHorizontalHeaderTable().getAscent();
this.fontSize = font.getSize(); final double ascent = fontData.getHorizontalHeaderTable().getAscent(); this.scale = fontSize / ascent;
public TTFFontMetrics(Font font, TTFFontData fontData) throws IOException { super(font); if (font == null) { throw new IllegalArgumentException("font cannot be null"); } if (fontData == null) { throw new IllegalArgumentException("fontData cannot be null"); } this.fontData = fontData; this.scale = font.getSize() / fontData.getHorizontalHeaderTable().getAscent(); }
return (int)(fontData.getHorizontalHeaderTable().getAscent() * scale);
final int ascent = (int)(fontData.getHorizontalHeaderTable().getAscent() * scale); return ascent;
public int getAscent() { try { return (int)(fontData.getHorizontalHeaderTable().getAscent() * scale); } catch (IOException ex) { return 0; } }
return Math.abs((int)(fontData.getHorizontalHeaderTable().getDescent() * scale));
final int descent = Math.abs((int)(fontData.getHorizontalHeaderTable().getDescent() * scale)); return descent;
public int getDescent() { try { return Math.abs((int)(fontData.getHorizontalHeaderTable().getDescent() * scale)); } catch (IOException ex) { return 0; } }
SecureRandom rnd = new SecureRandom ();
private static final BigInteger newR(final BigInteger N) { final int upper = (N.bitLength() + 7) / 8; final int lower = upper / 2; final byte[] bl = new byte[1]; SecureRandom rnd = new SecureRandom (); int b; do { rnd.nextBytes(bl); b = bl[0] & 0xFF; } while (b < lower || b > upper); final byte[] buffer = new byte[b]; // 256-bit MPI rnd.nextBytes(buffer); return new BigInteger(1, buffer); }
rnd.nextBytes(bl);
prng.nextBytes(bl);
private static final BigInteger newR(final BigInteger N) { final int upper = (N.bitLength() + 7) / 8; final int lower = upper / 2; final byte[] bl = new byte[1]; SecureRandom rnd = new SecureRandom (); int b; do { rnd.nextBytes(bl); b = bl[0] & 0xFF; } while (b < lower || b > upper); final byte[] buffer = new byte[b]; // 256-bit MPI rnd.nextBytes(buffer); return new BigInteger(1, buffer); }
rnd.nextBytes(buffer);
prng.nextBytes(buffer);
private static final BigInteger newR(final BigInteger N) { final int upper = (N.bitLength() + 7) / 8; final int lower = upper / 2; final byte[] bl = new byte[1]; SecureRandom rnd = new SecureRandom (); int b; do { rnd.nextBytes(bl); b = bl[0] & 0xFF; } while (b < lower || b > upper); final byte[] buffer = new byte[b]; // 256-bit MPI rnd.nextBytes(buffer); return new BigInteger(1, buffer); }
popupLocationX = point.x; popupLocationY = point.y;
popupLocationX += point.x; popupLocationY += point.y;
public void setVisible(final boolean visible) { // Hook up this call so that it gets executed on the event thread in order // to avoid synchronization problems when calling the layout manager. if (! SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { public void run() { setVisible(visible); } }); } if (visible == isVisible()) return; boolean old = isVisible();// @classpath-bugfix 6/9/2006 Martin Husted Hartvig ([email protected]) : if (old != visible) { if (visible) { if (invoker != null) { if (!(invoker instanceof JMenu)) { MenuElement[] menuEls; if (getSubElements().length > 0) { menuEls = new MenuElement[2]; menuEls[0] = this; menuEls[1] = getSubElements()[0]; } else { menuEls = new MenuElement[1]; menuEls[0] = this; } MenuSelectionManager.defaultManager().setSelectedPath(menuEls); } else { Point point = ((JMenu)invoker).getPopupMenuOrigin(); popupLocationX = point.x; popupLocationY = point.y; } } firePopupMenuWillBecomeVisible(); PopupFactory pf = PopupFactory.getSharedInstance(); pack(); popup = pf.getPopup(invoker, this, popupLocationX, popupLocationY); popup.show(); } else { getSelectionModel().clearSelection(); firePopupMenuWillBecomeInvisible(); popup.hide(); } this.visible = visible;// @classpath-bugfix-end firePropertyChange("visible", old, isVisible()); } }
LastFastAxisCoordinate = -1;
LastFastAxisCoordinate = 0; LastFieldAxisCoordinate = 0;
public Object action (SaxDocumentHandler handler, Attributes attrs) { // we only need to do these things for the first time we enter // a data node if (DataNodeLevel == 0) { // A little 'pre-handling' as href is a specialattribute // that will hold an (Href) object rather than string value Entity hrefObj = null; String hrefValue = getAttributesValueByName(attrs,"href"); if (hrefValue != null ) { // now we look up the href from the entity list gathered by // the parser and transfer relevant info to our Href object hrefObj = new Entity(); Hashtable hrefInfo = (Hashtable) UnParsedEntity.get(hrefValue); if (UnParsedEntity.containsKey(hrefValue)) { hrefObj.setName((String) hrefInfo.get("name"));/* if (hrefInfo.containsKey("base")) hrefObj.setBase((String) hrefInfo.get("base"));*/ if (hrefInfo.containsKey("systemId")) hrefObj.setSystemId((String) hrefInfo.get("systemId")); if (hrefInfo.containsKey("publicId")) hrefObj.setPublicId((String) hrefInfo.get("publicId")); if (hrefInfo.containsKey("ndata")) hrefObj.setNdata((String) hrefInfo.get("ndata")); } else { // bizarre. It usually means that the unparsed entity handler // isnt working like it should Log.error("Error: UnParsedEntity list lacks entry for :"+hrefValue); Log.errorln(" ignoring request to read data."); } } // update the array dataCube with passed attributes CurrentArray.getDataCube().setAttributes(attrs); // Clean up. We override the string value of Href and set it as // the Href object , if we created it (yeh, sloppy). if (hrefObj != null) CurrentArray.getDataCube().setHref(hrefObj); // determine the size of the dataFormat (s) in our dataCube if (CurrentArray.hasFieldAxis()) { // if there is a field axis, then its set to the number of fields FieldAxis fieldAxis = CurrentArray.getFieldAxis(); MaxDataFormatIndex = (fieldAxis.getLength()-1); } else { // its homogeneous MaxDataFormatIndex = 0; } // reset to start of which dataformat type we currently are reading CurrentDataFormatIndex = 0; // reset to start of which IOCmd we currently are reading CurrentIOCmdIndex = 0; // reset the list of dataformats we are reading DataFormatList = CurrentArray.getDataFormatList(); NrofDataFormats = DataFormatList.length; IntRadix = new int [NrofDataFormats]; // set up some other global information bout the dataformats // that will help speed reading CurrentReadBytes = 0; for (int i=0; i < NrofDataFormats; i++) { CurrentReadBytes += DataFormatList[i].numOfBytes(); if (DataFormatList[i] instanceof IntegerDataFormat) { String type = ((IntegerDataFormat) DataFormatList[i]).getType(); if (type.equals(Constants.INTEGER_TYPE_DECIMAL)) IntRadix[i] = 10; else if (type.equals(Constants.INTEGER_TYPE_HEX)) IntRadix[i] = 16; else if (type.equals(Constants.INTEGER_TYPE_OCTAL)) IntRadix[i] = 8; else IntRadix[i] = 10; // default } else if (DataFormatList[i] instanceof BinaryIntegerDataFormat) { IntRadix[i] = 10; } } if (CurrentReadBytes > MAXINPUTREADSIZE) { Log.errorln("This XDF file has single record that is too big (greater than "+MAXINPUTREADSIZE+" bytes in a record) to parse by this code"); System.exit(-1); } // now determine properread size CurrentInputReadSize = BASEINPUTREADSIZE * CurrentReadBytes; // make sure its not TOO big while (CurrentInputReadSize > MAXINPUTREADSIZE) { CurrentInputReadSize -= CurrentReadBytes; } } XMLDataIOStyle readObj = CurrentArray.getXMLDataIOStyle(); FastestAxis = (AxisInterface) CurrentArray.getAxes().get(0); LastFastAxisCoordinate = -1; if ( readObj instanceof TaggedXMLDataIOStyle) { TaggedLocatorObj = CurrentArray.createLocator(); } else { // A safety. We clear datablock when this is the first datanode we // have entered DATABLOCK is used in cases where we read in untagged data if (DataNodeLevel == 0) DATABLOCK = new StringBuffer (); } // tack in href data Entity href = CurrentArray.getDataCube().getHref(); if (href != null) // The first method is the 'old' way. // If you uncomment it be sure to uncomment line that looks like: // if (CurrentArray.getDataCube().getHref() != null) return; // in the end dataElementHandler // DATABLOCK.append(getHrefData(href, CurrentArray.getDataCube().getCompression())); loadHrefDataIntoCurrentArray(href, CurrentArray.getDataCube().getCompression()); // entered a datanode, raise the count // this (partially helps) declare we are now reading data, DataNodeLevel++; return readObj; }
int currentFastAxisCoordinate = TaggedLocatorObj.getAxisIndex(FastestAxis); if ( currentFastAxisCoordinate != LastFastAxisCoordinate )
int currentFieldAxisCoordinate = TaggedLocatorObj.getAxisIndex(CurrentArray.getFieldAxis()); if ( currentFieldAxisCoordinate != LastFieldAxisCoordinate )
public void action (SaxDocumentHandler handler) { if (CurrentDataTagLevel == DataTagLevel) TaggedLocatorObj.next(); // bump up DataFormat appropriately if (MaxDataFormatIndex > 0) { int currentFastAxisCoordinate = TaggedLocatorObj.getAxisIndex(FastestAxis); if ( currentFastAxisCoordinate != LastFastAxisCoordinate ) { LastFastAxisCoordinate = currentFastAxisCoordinate; if (CurrentDataFormatIndex == MaxDataFormatIndex) CurrentDataFormatIndex = 0; else CurrentDataFormatIndex++; } } CurrentDataTagLevel--; }
LastFastAxisCoordinate = currentFastAxisCoordinate;
LastFieldAxisCoordinate = currentFieldAxisCoordinate;
public void action (SaxDocumentHandler handler) { if (CurrentDataTagLevel == DataTagLevel) TaggedLocatorObj.next(); // bump up DataFormat appropriately if (MaxDataFormatIndex > 0) { int currentFastAxisCoordinate = TaggedLocatorObj.getAxisIndex(FastestAxis); if ( currentFastAxisCoordinate != LastFastAxisCoordinate ) { LastFastAxisCoordinate = currentFastAxisCoordinate; if (CurrentDataFormatIndex == MaxDataFormatIndex) CurrentDataFormatIndex = 0; else CurrentDataFormatIndex++; } } CurrentDataTagLevel--; }