rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
super(entry); | super(name); | public JarEntry(ZipEntry entry) { super(entry); attr = null; certs = null; } |
public int read(byte[] b, int off, int len) throws IOException | public int read() throws IOException | public int read(byte[] b, int off, int len) throws IOException { if (len == 0) return 0; if (crc == null) throw new IOException("Stream closed."); if (entry == null) return -1; boolean finished = false; switch (method) { case ZipOutputStream.DEFLATED: len = super.read(b, off, len); if (len < 0) { if (!inf.finished()) throw new ZipException("Inflater not finished!?"); avail = inf.getRemaining(); if ((flags & 8) != 0) readDataDescr(); if (inf.getTotalIn() != csize || inf.getTotalOut() != size) throw new ZipException("size mismatch: "+csize+";"+size+" <-> "+inf.getTotalIn()+";"+inf.getTotalOut()); inf.reset(); finished = true; } break; case ZipOutputStream.STORED: if (len > csize && csize >= 0) len = csize; len = readBuf(b, off, len); if (len > 0) { csize -= len; size -= len; } if (csize == 0) finished = true; else if (len < 0) throw new ZipException("EOF in stored block"); break; } if (len > 0) crc.update(b, off, len); if (finished) { if ((crc.getValue() & 0xffffffffL) != entry.getCrc()) throw new ZipException("CRC mismatch"); crc.reset(); entry = null; entryAtEOF = true; } return len; } |
if (len == 0) return 0; if (crc == null) throw new IOException("Stream closed."); if (entry == null) | byte[] b = new byte[1]; if (read(b, 0, 1) <= 0) | public int read(byte[] b, int off, int len) throws IOException { if (len == 0) return 0; if (crc == null) throw new IOException("Stream closed."); if (entry == null) return -1; boolean finished = false; switch (method) { case ZipOutputStream.DEFLATED: len = super.read(b, off, len); if (len < 0) { if (!inf.finished()) throw new ZipException("Inflater not finished!?"); avail = inf.getRemaining(); if ((flags & 8) != 0) readDataDescr(); if (inf.getTotalIn() != csize || inf.getTotalOut() != size) throw new ZipException("size mismatch: "+csize+";"+size+" <-> "+inf.getTotalIn()+";"+inf.getTotalOut()); inf.reset(); finished = true; } break; case ZipOutputStream.STORED: if (len > csize && csize >= 0) len = csize; len = readBuf(b, off, len); if (len > 0) { csize -= len; size -= len; } if (csize == 0) finished = true; else if (len < 0) throw new ZipException("EOF in stored block"); break; } if (len > 0) crc.update(b, off, len); if (finished) { if ((crc.getValue() & 0xffffffffL) != entry.getCrc()) throw new ZipException("CRC mismatch"); crc.reset(); entry = null; entryAtEOF = true; } return len; } |
boolean finished = false; switch (method) { case ZipOutputStream.DEFLATED: len = super.read(b, off, len); if (len < 0) { if (!inf.finished()) throw new ZipException("Inflater not finished!?"); avail = inf.getRemaining(); if ((flags & 8) != 0) readDataDescr(); if (inf.getTotalIn() != csize || inf.getTotalOut() != size) throw new ZipException("size mismatch: "+csize+";"+size+" <-> "+inf.getTotalIn()+";"+inf.getTotalOut()); inf.reset(); finished = true; } break; case ZipOutputStream.STORED: if (len > csize && csize >= 0) len = csize; len = readBuf(b, off, len); if (len > 0) { csize -= len; size -= len; } if (csize == 0) finished = true; else if (len < 0) throw new ZipException("EOF in stored block"); break; } if (len > 0) crc.update(b, off, len); if (finished) { if ((crc.getValue() & 0xffffffffL) != entry.getCrc()) throw new ZipException("CRC mismatch"); crc.reset(); entry = null; entryAtEOF = true; } return len; | return b[0] & 0xff; | public int read(byte[] b, int off, int len) throws IOException { if (len == 0) return 0; if (crc == null) throw new IOException("Stream closed."); if (entry == null) return -1; boolean finished = false; switch (method) { case ZipOutputStream.DEFLATED: len = super.read(b, off, len); if (len < 0) { if (!inf.finished()) throw new ZipException("Inflater not finished!?"); avail = inf.getRemaining(); if ((flags & 8) != 0) readDataDescr(); if (inf.getTotalIn() != csize || inf.getTotalOut() != size) throw new ZipException("size mismatch: "+csize+";"+size+" <-> "+inf.getTotalIn()+";"+inf.getTotalOut()); inf.reset(); finished = true; } break; case ZipOutputStream.STORED: if (len > csize && csize >= 0) len = csize; len = readBuf(b, off, len); if (len > 0) { csize -= len; size -= len; } if (csize == 0) finished = true; else if (len < 0) throw new ZipException("EOF in stored block"); break; } if (len > 0) crc.update(b, off, len); if (finished) { if ((crc.getValue() & 0xffffffffL) != entry.getCrc()) throw new ZipException("CRC mismatch"); crc.reset(); entry = null; entryAtEOF = true; } return len; } |
for (Iterator<FSEntry> i = entry.getDirectory().iterator(); i.hasNext();) { | for (Iterator<? extends FSEntry> i = entry.getDirectory().iterator(); i.hasNext();) { | public String[] list(String directory) throws IOException { final FSEntry entry = getEntry(directory); if (entry == null) { throw new FileNotFoundException(directory); } if (!entry.isDirectory()) { throw new IOException("Cannot list on non-directories " + directory); } final ArrayList<String> list = new ArrayList<String>(); for (Iterator<FSEntry> i = entry.getDirectory().iterator(); i.hasNext();) { final FSEntry child = i.next(); final String name = child.getName(); list.add(name); } return list.toArray(new String[list.size()]); } |
public static DataBuffer createBuffer(int dataType, int size) { return createBuffer(dataType, size, 1); | public static DataBuffer createBuffer(int dataType, Object data, int size) { if (data == null) return createBuffer(dataType, size, 1); return createBufferFromData(dataType, data, size); | public static DataBuffer createBuffer(int dataType, int size) { return createBuffer(dataType, size, 1); } |
<T> T[] toArray(T[] a); | Object[] toArray(); | <T> T[] toArray(T[] a); |
textComponent.setBackground(background); | protected void installDefaults() { Caret caret = textComponent.getCaret(); if (caret == null) { caret = createCaret(); textComponent.setCaret(caret); } Highlighter highlighter = textComponent.getHighlighter(); if (highlighter == null) textComponent.setHighlighter(createHighlighter()); String prefix = getPropertyPrefix(); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); textComponent.setMargin(defaults.getInsets(prefix + ".margin")); textComponent.setBorder(defaults.getBorder(prefix + ".border")); textComponent.setFont(defaults.getFont(prefix + ".font")); caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate")); // Fetch the colors for enabled/disabled text components. background = defaults.getColor(prefix + ".background"); inactiveBackground = defaults.getColor(prefix + ".inactiveBackground"); textComponent.setForeground(defaults.getColor(prefix + ".foreground")); textComponent.setDisabledTextColor (defaults.getColor(prefix + ".inactiveForeground")); } |
|
public View create(Element elem); | View create (Element elem); | public View create(Element elem); |
public Object getValue(String key); | Object getValue(String key); | public Object getValue(String key); |
return super.get(key); | return this.get (key, getDefaultLocale ()); | public Object get(Object key) { // XXX Obey 1.4 specs return super.get(key); } |
throw new Error("not implemented"); | Object old = super.put (key, value); if (key instanceof String && old != value) firePropertyChange ((String) key, old, value); return old; | public Object put(Object key, Object value) { throw new Error("not implemented"); } |
Dimension d = new Dimension(100,100); return d; | return null; | public Dimension getPreferredSize(JComponent c) { // FIXME: integrate with Scrollable Dimension d = new Dimension(100,100); return d; } |
c.setOpaque(true); | void installDefaults(JComponent c) { } |
|
c.setLayout(new ViewportLayout()); | public void installUI(JComponent c) { super.installUI(c); installListeners(c); } |
|
if (c.getBackground() != null) { java.awt.Color save = g2.getColor(); g2.setColor(c.getBackground()); g2.fillRect (0, 0, backingStoreWidth, backingStoreHeight); g2.setColor(save); save = g.getColor(); g.setColor(c.getBackground()); g.fillRect (0, 0, portBounds.width, portBounds.height); g.setColor(save); } else { g2.clearRect(0, 0, backingStoreWidth, backingStoreHeight); g.clearRect(0, 0, portBounds.width, portBounds.height); } | public void paint(Graphics g, JComponent c) { JViewport v = (JViewport)c; Component view = v.getView(); if (view == null) return; Point pos = v.getViewPosition(); Rectangle viewBounds = view.getBounds(); if (backingStoreImage == null || backingStoreWidth != viewBounds.width || backingStoreHeight != viewBounds.height) { backingStoreImage = v.createImage(viewBounds.width, viewBounds.height); backingStoreWidth = viewBounds.width; backingStoreHeight = viewBounds.height; } Graphics g2 = backingStoreImage.getGraphics(); view.paint(g2); g2 = null; g.drawImage(backingStoreImage, -pos.x, -pos.y, (ImageObserver)null); } |
|
Dimension viewportSize = new Dimension(0,0); Dimension viewSize = new Dimension(0,0); | public void layoutContainer(Container parent) { if (parent instanceof JScrollPane) { JScrollPane sc = (JScrollPane) parent; synchronized (sc.getTreeLock ()) { Rectangle scrollPaneBounds = sc.getBounds(); Dimension viewportSize = new Dimension(0,0); Dimension viewSize = new Dimension(0,0); JViewport viewport = sc.getViewport(); int x1 = 0, x2 = 0, x3 = 0, x4 = 0; int y1 = 0, y2 = 0, y3 = 0, y4 = 0; x1 = scrollPaneBounds.x; y1 = scrollPaneBounds.y; x4 = scrollPaneBounds.x + scrollPaneBounds.width; y4 = scrollPaneBounds.y + scrollPaneBounds.height; if (columnHeader != null) y2 = columnHeader.getPreferredSize().height; else y2 = y1; if (rowHeader != null) x2 = rowHeader.getPreferredSize().width; else x2 = x1; int vsbPolicy = sc.getVerticalScrollBarPolicy(); int hsbPolicy = sc.getHorizontalScrollBarPolicy(); boolean showVsb = (verticalScrollBar != null) && ((vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) || (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED && viewSize.height > viewportSize.height)); boolean showHsb = (horizontalScrollBar != null) && ((hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS) || (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED && viewSize.width > viewportSize.width)); if (showVsb) x3 = x4 - verticalScrollBar.getPreferredSize().width; else x3 = x4; if (showHsb) y3 = y4 - horizontalScrollBar.getPreferredSize().height; else y3 = y4; // now set the layout if (viewport != null) viewport.setBounds(new Rectangle(x2, y2, x3-x2, y3-y2)); if (columnHeader != null) columnHeader.setBounds(new Rectangle(x2, y1, x3-x2, y2-y1)); if (rowHeader != null) rowHeader.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2)); if (showVsb) verticalScrollBar.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2)); if (showHsb) horizontalScrollBar.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3)); if (upperLeft != null) upperLeft.setBounds(new Rectangle(x1, y1, x2-x1, y2-y1)); if (upperRight != null) upperRight.setBounds(new Rectangle(x3, y1, x4-x3, y2-y1)); if (lowerLeft != null) lowerLeft.setBounds(new Rectangle(x1, y3, x2-x1, y4-y3)); if (lowerRight != null) lowerRight.setBounds(new Rectangle(x3, y3, x4-x3, y4-y3)); } } } |
|
Dimension viewportSize = viewport.getSize(); Dimension viewSize = viewport.getView().getSize(); | public void layoutContainer(Container parent) { if (parent instanceof JScrollPane) { JScrollPane sc = (JScrollPane) parent; synchronized (sc.getTreeLock ()) { Rectangle scrollPaneBounds = sc.getBounds(); Dimension viewportSize = new Dimension(0,0); Dimension viewSize = new Dimension(0,0); JViewport viewport = sc.getViewport(); int x1 = 0, x2 = 0, x3 = 0, x4 = 0; int y1 = 0, y2 = 0, y3 = 0, y4 = 0; x1 = scrollPaneBounds.x; y1 = scrollPaneBounds.y; x4 = scrollPaneBounds.x + scrollPaneBounds.width; y4 = scrollPaneBounds.y + scrollPaneBounds.height; if (columnHeader != null) y2 = columnHeader.getPreferredSize().height; else y2 = y1; if (rowHeader != null) x2 = rowHeader.getPreferredSize().width; else x2 = x1; int vsbPolicy = sc.getVerticalScrollBarPolicy(); int hsbPolicy = sc.getHorizontalScrollBarPolicy(); boolean showVsb = (verticalScrollBar != null) && ((vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) || (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED && viewSize.height > viewportSize.height)); boolean showHsb = (horizontalScrollBar != null) && ((hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS) || (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED && viewSize.width > viewportSize.width)); if (showVsb) x3 = x4 - verticalScrollBar.getPreferredSize().width; else x3 = x4; if (showHsb) y3 = y4 - horizontalScrollBar.getPreferredSize().height; else y3 = y4; // now set the layout if (viewport != null) viewport.setBounds(new Rectangle(x2, y2, x3-x2, y3-y2)); if (columnHeader != null) columnHeader.setBounds(new Rectangle(x2, y1, x3-x2, y2-y1)); if (rowHeader != null) rowHeader.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2)); if (showVsb) verticalScrollBar.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2)); if (showHsb) horizontalScrollBar.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3)); if (upperLeft != null) upperLeft.setBounds(new Rectangle(x1, y1, x2-x1, y2-y1)); if (upperRight != null) upperRight.setBounds(new Rectangle(x3, y1, x4-x3, y2-y1)); if (lowerLeft != null) lowerLeft.setBounds(new Rectangle(x1, y3, x2-x1, y4-y3)); if (lowerRight != null) lowerRight.setBounds(new Rectangle(x3, y3, x4-x3, y4-y3)); } } } |
|
public void setSize(int w, int h) | public void setSize(double w, double h) | public void setSize(int w, int h) { width = w; height = h; } |
width = w; height = h; | width = (int) w; height = (int) h; | public void setSize(int w, int h) { width = w; height = h; } |
else if (parent != null && parent.isLightweight()) new HeavyweightInLightweightListener(parent); | public void addNotify() { if (peer == null) peer = getToolkit().createComponent(this); /* Now that all the children has gotten their peers, we should have the event mask needed for this component and its lightweight subcomponents. */ peer.setEventMask(eventMask); /* We do not invalidate here, but rather leave that job up to the peer. For efficiency, the peer can choose not to invalidate if it is happy with the current dimensions, etc. */ } |
|
return (node.getParent() == getParent() && getParent() != null); | return node.getParent() == getParent() && getParent() != null; | public boolean isNodeSibling(TreeNode node) { if (node == null) return false; if (node == this) return true; return (node.getParent() == getParent() && getParent() != null); } |
super("Windows-1251", new String[] { | super("windows-1251", new String[] { | public Windows1251() { super("Windows-1251", new String[] { "Windows1251", "cp1251", "cp-1251", "cp_1251", "windows1251", "windows_1251" }); lookupTable = lookup; } |
os.writeLEA(itemReg, itemReg, index.getRegister(), os.getWordSize(), VmArray.DATA_OFFSET * os.getWordSize()); | GPR indexReg = index.getRegister(); if (os.isCode64()) { GPR64 indexReg64 = L1AHelper.get64BitReg(ec, indexReg); os.writeMOVSXD(indexReg64, (GPR32)indexReg); indexReg = indexReg64; } os.writeLEA(itemReg, itemReg, indexReg, os.getWordSize(), VmArray.DATA_OFFSET * os.getWordSize()); | public void emitMagic(EmitterContext ec, VmMethod method, boolean isstatic, X86BytecodeVisitor bcv, VmMethod caller) { //final int type = getClass(method); final MagicMethod mcode = MagicMethod.get(method); final VirtualStack vstack = ec.getVStack(); final X86Assembler os = ec.getStream(); final ItemFactory ifac = ec.getItemFactory(); final X86RegisterPool pool = ec.getGPRPool();// final EntryPoints context = ec.getContext(); final X86CompilerHelper helper = ec.getHelper(); final int slotSize = os.isCode32() ? 4 : 8; // Test magic permission first testMagicPermission(mcode, caller); switch (mcode) { case ADD: { // addr + ofs if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem ofs = (WordItem) vstack.pop(); final RefItem addr = vstack.popRef(); ofs.load(ec); addr.load(ec); GPR ofsr = ofs.getRegister(); final GPR addrr = addr.getRegister(); if (ofsr.getSize() != addrr.getSize()) { // Sign-extend offset final GPR64 ofsr64 = (GPR64)pool.getRegisterInSameGroup(ofsr, JvmType.REFERENCE); os.writeMOVSXD(ofsr64, (GPR32)ofsr); ofsr = ofsr64; } os.writeADD(addrr, ofsr); ofs.release(ec); vstack.push(addr); } break; case AND: { // addr & ofs if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem ofs = (WordItem) vstack.pop(); final RefItem addr = vstack.popRef(); ofs.load(ec); addr.load(ec); GPR ofsr = ofs.getRegister(); final GPR addrr = addr.getRegister(); if (ofsr.getSize() != addrr.getSize()) { // Sign-extend offset final GPR64 ofsr64 = (GPR64)pool.getRegisterInSameGroup(ofsr, JvmType.REFERENCE); os.writeMOVSXD(ofsr64, (GPR32)ofsr); ofsr = ofsr64; } os.writeAND(addrr, ofsr); ofs.release(ec); vstack.push(addr); } break; case OR: { // addr | ofs if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem ofs = (WordItem) vstack.pop(); final RefItem addr = vstack.popRef(); ofs.load(ec); addr.load(ec); GPR ofsr = ofs.getRegister(); final GPR addrr = addr.getRegister(); if (ofsr.getSize() != addrr.getSize()) { // Sign-extend offset final GPR64 ofsr64 = (GPR64)pool.getRegisterInSameGroup(ofsr, JvmType.REFERENCE); os.writeMOVSXD(ofsr64, (GPR32)ofsr); ofsr = ofsr64; } os.writeOR(addrr, ofsr); ofs.release(ec); vstack.push(addr); } break; case SUB: case DIFF: { // addr - ofs if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem ofs = (WordItem) vstack.pop(); final RefItem addr = vstack.popRef(); ofs.load(ec); addr.load(ec); GPR ofsr = ofs.getRegister(); final GPR addrr = addr.getRegister(); if (ofsr.getSize() != addrr.getSize()) { // Sign-extend offset final GPR64 ofsr64 = (GPR64)pool.getRegisterInSameGroup(ofsr, JvmType.REFERENCE); os.writeMOVSXD(ofsr64, (GPR32)ofsr); ofsr = ofsr64; } os.writeSUB(addrr, ofsr); ofs.release(ec); vstack.push(addr); } break; case XOR: { // addr ^ ofs if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem ofs = (WordItem) vstack.pop(); final RefItem addr = vstack.popRef(); ofs.load(ec); addr.load(ec); GPR ofsr = ofs.getRegister(); final GPR addrr = addr.getRegister(); if (ofsr.getSize() != addrr.getSize()) { // Sign-extend offset final GPR64 ofsr64 = (GPR64)pool.getRegisterInSameGroup(ofsr, JvmType.REFERENCE); os.writeMOVSXD(ofsr64, (GPR32)ofsr); ofsr = ofsr64; } os.writeXOR(addrr, ofsr); ofs.release(ec); vstack.push(addr); } break; case NOT: { // !addr if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem addr = vstack.popRef(); addr.load(ec); os.writeNOT(addr.getRegister()); vstack.push(addr); } break; case TOINT: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem addr = vstack.popRef(); addr.load(ec); X86Register r = addr.getRegister(); if (os.isCode64()) { r = pool.getRegisterInSameGroup(r, JvmType.INT); // We just take the lower 32-bit, so no actual mov's needed. } addr.release(ec); L1AHelper.requestRegister(ec, r); final IntItem result = (IntItem) ifac.createReg(ec, JvmType.INT, r); pool.transferOwnerTo(r, result); vstack.push(result); } break; case TOWORD: case TOADDRESS: case TOOFFSET: case TOOBJECT: case TOOBJECTREFERENCE: case TOEXTENT: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem addr = vstack.popRef(); vstack.push(addr); } break; case TOLONG: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem addr = vstack.popRef(); addr.load(ec); final X86Register.GPR r = addr.getRegister(); addr.release(ec); L1AHelper.requestRegister(ec, r); final LongItem result; if (os.isCode32()) { final X86Register.GPR msb = (X86Register.GPR)L1AHelper.requestRegister(ec, JvmType.INT, false); result = (LongItem) ifac.createReg(ec, JvmType.LONG, r, msb); os.writeXOR(msb, msb); pool.transferOwnerTo(msb, result); } else { result = (LongItem) ifac.createReg(ec, JvmType.LONG, (GPR64)r); } pool.transferOwnerTo(r, result); vstack.push(result); } break; case MAX: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem result = (RefItem) L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, false); final GPR r = result.getRegister(); os.writeMOV_Const(r, -1); vstack.push(result); } break; case ONE: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem result = (RefItem) L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, false); final GPR r = result.getRegister(); os.writeMOV_Const(r, 1); vstack.push(result); } break; case ZERO: case NULLREFERENCE: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem result = ifac.createAConst(ec, null); vstack.push(result); } break; case SIZE: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final IntItem result = ifac.createIConst(ec, slotSize); vstack.push(result); break; } case ISMAX: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem addr = vstack.popRef(); addr.load(ec); final IntItem result = (IntItem)L1AHelper.requestWordRegister(ec, JvmType.INT, true); final GPR addrr = addr.getRegister(); final GPR resultr = result.getRegister(); os.writeXOR(resultr, resultr); os.writeCMP_Const(addrr, -1); os.writeSETCC(resultr, X86Constants.JE); addr.release(ec); vstack.push(result); } break; case ISZERO: case ISNULL: { // Just convert to int if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem addr = vstack.popRef(); addr.load(ec); final IntItem result = (IntItem)L1AHelper.requestWordRegister(ec, JvmType.INT, true); final GPR addrr = addr.getRegister(); final GPR resultr = result.getRegister(); os.writeXOR(resultr, resultr); os.writeTEST(addrr, addrr); os.writeSETCC(resultr, X86Constants.JZ); addr.release(ec); vstack.push(result); } break; case EQUALS: case EQ: case NE: case LT: case LE: case GE: case GT: case SLT: case SLE: case SGE: case SGT: { // addr .. other if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem other = vstack.popRef(); final RefItem addr = vstack.popRef(); other.load(ec); addr.load(ec); final IntItem result = (IntItem)L1AHelper.requestWordRegister(ec, JvmType.INT, true); final GPR resultr = result.getRegister(); os.writeXOR(resultr, resultr); os.writeCMP(addr.getRegister(), other.getRegister()); os.writeSETCC(resultr, methodToCC(mcode)); other.release(ec); addr.release(ec); vstack.push(result); } break; case FROMINT: case FROMINTSIGNEXTEND: case FROMINTZEROEXTEND: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final WordItem addr = vstack.popInt(); addr.load(ec); GPR r = addr.getRegister(); if (os.isCode64()) { final GPR64 newR = (GPR64)pool.getRegisterInSameGroup(r, JvmType.REFERENCE); if (mcode == FROMINTZEROEXTEND) { // Moving the register to itself in 32-bit mode, will // zero extend the top 32-bits. os.writeMOV(BITS32, r, r); } else { // Sign extend os.writeMOVSXD(newR, (GPR32)r); } r = newR; } addr.release(ec); vstack.push(L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, r)); } break; case FROMADDRESS: case FROMOBJECT: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem obj = vstack.popRef(); // Do nothing vstack.push(obj); } break; case FROMLONG: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final LongItem addr = vstack.popLong(); addr.load(ec); final X86Register r; if (os.isCode32()) { r = addr.getLsbRegister(ec); } else { r = addr.getRegister(ec); } addr.release(ec); vstack.push(L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, r)); } break; case LSH: case RSHA: case RSHL: { // addr shift cnt if (Vm.VerifyAssertions) Vm._assert(!isstatic); final GPR ECX = X86Register.ECX; final IntItem cnt = vstack.popInt(); final RefItem addr = vstack.popRef(); if (!cnt.isConstant() && !cnt.uses(ECX)) { addr.spillIfUsing(ec, ECX); L1AHelper.requestRegister(ec, ECX); cnt.loadTo(ec, ECX); } addr.load(ec); final int shift = methodToShift(mcode); if (cnt.isConstant()) { os.writeShift(shift, addr.getRegister(), cnt.getValue()); } else { os.writeShift_CL(shift, addr.getRegister()); } cnt.release(ec); vstack.push(addr); } break; case LOADBYTE: case LOADCHAR: case LOADSHORT: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem addr = vstack.popRef(); addr.loadToBITS8GPR(ec); final GPR r = addr.getRegister(); final WordItem result = L1AHelper.requestWordRegister(ec, methodToType(mcode), true); final GPR resultr = result.getRegister(); if (mcode == LOADCHAR) { os.writeMOVZX(resultr, r, 0, methodToSize(mcode)); } else { os.writeMOVSX(resultr, r, 0, methodToSize(mcode)); } addr.release(ec); vstack.push(result); } break; case LOADINT: case LOADFLOAT: case LOADADDRESS: case LOADOBJECTREFERENCE: case LOADWORD: case PREPAREINT: case PREPAREADDRESS: case PREPAREOBJECTREFERENCE: case PREPAREWORD: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem addr = vstack.popRef(); addr.load(ec); final GPR r = addr.getRegister(); final WordItem result = L1AHelper.requestWordRegister(ec, methodToType(mcode), false); final GPR resultr = result.getRegister(); os.writeMOV(resultr.getSize(), resultr, r, 0); addr.release(ec); vstack.push(result); } break; case LOADLONG: case LOADDOUBLE: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem addr = vstack.popRef(); addr.load(ec); final X86Register.GPR r = addr.getRegister(); if (os.isCode32()) { final X86Register.GPR msb = (X86Register.GPR)L1AHelper.requestRegister(ec, JvmType.INT, false); addr.release(ec); L1AHelper.releaseRegister(ec, msb); os.writeMOV(X86CompilerConstants.INTSIZE, msb, r, X86CompilerConstants.MSB); os.writeMOV(X86CompilerConstants.INTSIZE, r, r, X86CompilerConstants.LSB); vstack.push(L1AHelper.requestDoubleWordRegisters(ec, methodToType(mcode), r, msb)); } else { final DoubleWordItem result = L1AHelper.requestDoubleWordRegisters(ec, methodToType(mcode)); os.writeMOV(BITS64, result.getRegister(ec), r, 0); addr.release(ec); vstack.push(result); } } break; case LOADBYTE_OFS: case LOADCHAR_OFS: case LOADSHORT_OFS: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem ofs = vstack.popRef(); final RefItem addr = vstack.popRef(); ofs.load(ec); addr.load(ec); final GPR ofsr = ofs.getRegister(); final GPR r = addr.getRegister(); os.writeLEA(r, r, ofsr, 1, 0); final WordItem result = L1AHelper.requestWordRegister(ec, methodToType(mcode), true); final GPR resultr = result.getRegister(); if (mcode == LOADCHAR_OFS) { os.writeMOVZX(resultr, r, 0, methodToSize(mcode)); } else { os.writeMOVSX(resultr, r, 0, methodToSize(mcode)); } ofs.release(ec); addr.release(ec); vstack.push(result); } break; case LOADINT_OFS: case LOADFLOAT_OFS: case LOADADDRESS_OFS: case LOADOBJECTREFERENCE_OFS: case LOADWORD_OFS: case PREPAREINT_OFS: case PREPAREADDRESS_OFS: case PREPAREOBJECTREFERENCE_OFS: case PREPAREWORD_OFS: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem ofs = vstack.popRef(); final RefItem addr = vstack.popRef(); ofs.load(ec); addr.load(ec); final GPR ofsr = ofs.getRegister(); final GPR r = addr.getRegister(); final WordItem result = L1AHelper.requestWordRegister(ec, methodToType(mcode), false); final GPR resultr = result.getRegister(); os.writeMOV(resultr.getSize(), resultr, r, ofsr, 1, 0); ofs.release(ec); addr.release(ec); vstack.push(result); } break; case LOADLONG_OFS: case LOADDOUBLE_OFS: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem ofs = vstack.popRef(); final RefItem addr = vstack.popRef(); ofs.load(ec); addr.load(ec); final GPR ofsr = ofs.getRegister(); final GPR r = addr.getRegister(); if (os.isCode32()) { final GPR msb = (GPR)L1AHelper.requestRegister(ec, JvmType.INT, false); os.writeMOV(X86CompilerConstants.INTSIZE, msb, r, ofsr, 1, X86CompilerConstants.MSB); os.writeMOV(X86CompilerConstants.INTSIZE, r, r, ofsr, 1, X86CompilerConstants.LSB); ofs.release(ec); addr.release(ec); L1AHelper.releaseRegister(ec, msb); vstack.push(L1AHelper.requestDoubleWordRegisters(ec, methodToType(mcode), r, msb)); } else { final DoubleWordItem result = L1AHelper.requestDoubleWordRegisters(ec, methodToType(mcode)); os.writeMOV(BITS64, result.getRegister(ec), r, ofsr, 1, 0); addr.release(ec); ofs.release(ec); vstack.push(result); } } break; case STOREBYTE: case STORECHAR: case STORESHORT: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final IntItem val = vstack.popInt(); final RefItem addr = vstack.popRef(); val.loadToBITS8GPR(ec); addr.load(ec); final GPR r = addr.getRegister(); final GPR valr = val.getRegister(); os.writeMOV(methodToSize(mcode), r, 0, valr); val.release(ec); addr.release(ec); } break; case STOREINT: case STOREFLOAT: case STOREADDRESS: case STOREOBJECTREFERENCE: case STOREWORD: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem val = (WordItem)vstack.pop(); final RefItem addr = vstack.popRef(); val.load(ec); addr.load(ec); final GPR r = addr.getRegister(); final GPR valr = val.getRegister(); os.writeMOV(valr.getSize(), r, 0, valr); val.release(ec); addr.release(ec); } break; case STORELONG: case STOREDOUBLE: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final DoubleWordItem val = (DoubleWordItem)vstack.pop(); final RefItem addr = vstack.popRef(); val.load(ec); addr.load(ec); final GPR r = addr.getRegister(); if (os.isCode32()) { final GPR lsb = val.getLsbRegister(ec); final GPR msb = val.getMsbRegister(ec); os.writeMOV(X86CompilerConstants.INTSIZE, r, X86CompilerConstants.LSB, lsb); os.writeMOV(X86CompilerConstants.INTSIZE, r, X86CompilerConstants.MSB, msb); } else { final GPR64 valr = val.getRegister(ec); os.writeMOV(BITS64, r, 0, valr); } val.release(ec); addr.release(ec); } break; case STOREBYTE_OFS: case STORECHAR_OFS: case STORESHORT_OFS: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem ofs = vstack.popRef(); final IntItem val = vstack.popInt(); final RefItem addr = vstack.popRef(); ofs.load(ec); val.loadToBITS8GPR(ec); addr.load(ec); final GPR r = addr.getRegister(); final GPR ofsr = ofs.getRegister(); final GPR valr = val.getRegister(); os.writeMOV(methodToSize(mcode), r, ofsr, 1, 0, valr); ofs.release(ec); val.release(ec); addr.release(ec); } break; case STOREINT_OFS: case STOREFLOAT_OFS: case STOREADDRESS_OFS: case STOREOBJECTREFERENCE_OFS: case STOREWORD_OFS: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem ofs = vstack.popRef(); final WordItem val = (WordItem)vstack.pop(); final RefItem addr = vstack.popRef(); ofs.load(ec); val.load(ec); addr.load(ec); final GPR r = addr.getRegister(); final GPR ofsr = ofs.getRegister(); final GPR valr = val.getRegister(); os.writeMOV(valr.getSize(), r, ofsr, 1, 0, valr); ofs.release(ec); val.release(ec); addr.release(ec); } break; case STORELONG_OFS: case STOREDOUBLE_OFS: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem ofs = vstack.popRef(); final DoubleWordItem val = (DoubleWordItem)vstack.pop(); final RefItem addr = vstack.popRef(); ofs.load(ec); val.load(ec); addr.load(ec); final GPR r = addr.getRegister(); final GPR ofsr = ofs.getRegister(); if (os.isCode32()) { final GPR lsb = val.getLsbRegister(ec); final GPR msb = val.getMsbRegister(ec); os.writeMOV(X86CompilerConstants.INTSIZE, r, ofsr, 1, X86CompilerConstants.LSB, lsb); os.writeMOV(X86CompilerConstants.INTSIZE, r, ofsr, 1, X86CompilerConstants.MSB, msb); } else { final GPR64 valr = val.getRegister(ec); os.writeMOV(BITS64, r, ofsr, 1, 0, valr); } ofs.release(ec); val.release(ec); addr.release(ec); } break; case ATTEMPTINT: case ATTEMPTADDRESS: case ATTEMPTOBJECTREFERENCE: case ATTEMPTWORD: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final WordItem val = (WordItem)vstack.pop(); final WordItem old = (WordItem)vstack.pop(); final RefItem addr = vstack.popRef(); final X86Register.GPR aax; if ((mcode == ATTEMPTINT) || os.isCode32()) { aax = X86Register.EAX; } else { aax = X86Register.RAX; } if (!old.uses(aax)) { L1AHelper.requestRegister(ec, aax, old); val.load(ec); old.loadTo(ec, aax); } else { val.load(ec); } addr.load(ec); final IntItem result = (IntItem)L1AHelper.requestWordRegister(ec, JvmType.INT, true); final GPR resultr = result.getRegister(); final GPR r = addr.getRegister(); final GPR valr = val.getRegister(); os.writeCMPXCHG_EAX(r, 0, valr, true); os.writeSETCC(resultr, X86Constants.JZ); os.writeAND(resultr, 0xFF); val.release(ec); old.release(ec); addr.release(ec); vstack.push(result); } break; case ATTEMPTINT_OFS: case ATTEMPTADDRESS_OFS: case ATTEMPTOBJECTREFERENCE_OFS: case ATTEMPTWORD_OFS: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem ofs = vstack.popRef(); final WordItem val = (WordItem)vstack.pop(); final WordItem old = (WordItem)vstack.pop(); final RefItem addr = vstack.popRef(); final X86Register.GPR aax; if ((mcode == ATTEMPTINT) || os.isCode32()) { aax = X86Register.EAX; } else { aax = X86Register.RAX; } if (!old.uses(aax)) { L1AHelper.requestRegister(ec, aax, old); ofs.load(ec); val.load(ec); old.loadTo(ec, aax); } else { ofs.load(ec); val.load(ec); } addr.load(ec); final IntItem result = (IntItem)L1AHelper.requestWordRegister(ec, JvmType.INT, true); final GPR resultr = result.getRegister(); final GPR r = addr.getRegister(); final GPR valr = val.getRegister(); final GPR ofsr = ofs.getRegister(); os.writeLEA(r, r, ofsr, 1, 0); os.writeCMPXCHG_EAX(r, 0, valr, true); os.writeSETCC(resultr, X86Constants.JZ); os.writeAND(resultr, 0xFF); ofs.release(ec); val.release(ec); old.release(ec); addr.release(ec); vstack.push(L1AHelper.requestWordRegister(ec, JvmType.INT, resultr)); } break; case GETOBJECTTYPE: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem obj = vstack.popRef(); obj.load(ec); final GPR r = obj.getRegister(); final RefItem result = (RefItem)L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, false); final GPR resultr = result.getRegister(); // Get TIB os.writeMOV(helper.ADDRSIZE, r, r, ObjectLayout.TIB_SLOT * slotSize); // Get VmType os.writeMOV(helper.ADDRSIZE, resultr, r, (TIBLayout.VMTYPE_INDEX + VmArray.DATA_OFFSET) * slotSize); obj.release(ec); vstack.push(result); } break; case GETTIB: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem obj = vstack.popRef(); obj.load(ec); final GPR r = obj.getRegister(); // Get TIB os.writeMOV(helper.ADDRSIZE, r, r, ObjectLayout.TIB_SLOT * slotSize); vstack.push(obj); } break; case GETOBJECTFLAGS: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem obj = vstack.popRef(); obj.load(ec); final GPR r = obj.getRegister(); // Get flags os.writeMOV(helper.ADDRSIZE, r, r, ObjectLayout.FLAGS_SLOT * slotSize); obj.release(ec); vstack.push(L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, r)); } break; case SETOBJECTFLAGS: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem flags = vstack.popRef(); final RefItem obj = vstack.popRef(); flags.load(ec); obj.load(ec); final GPR flagsr = flags.getRegister(); final GPR r = obj.getRegister(); // Set flags os.writeMOV(helper.ADDRSIZE, r, ObjectLayout.FLAGS_SLOT * slotSize, flagsr); flags.release(ec); obj.release(ec); } break; case GETARRAYDATA: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem obj = vstack.popRef(); obj.load(ec); final GPR r = obj.getRegister(); os.writeADD(r, VmArray.DATA_OFFSET * slotSize); vstack.push(obj); } break; case GETOBJECTCOLOR: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem obj = vstack.popRef(); obj.load(ec); final GPR r = obj.getRegister(); final IntItem result = (IntItem)L1AHelper.requestWordRegister(ec, JvmType.INT, false); final GPR resultr = result.getRegister(); // Get flags os.writeMOV(BITS32, resultr, r, ObjectLayout.FLAGS_SLOT * slotSize); os.writeAND(resultr, ObjectFlags.GC_COLOUR_MASK); obj.release(ec); vstack.push(result); } break; case ISFINALIZED: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem obj = vstack.popRef(); obj.load(ec); final GPR r = obj.getRegister(); final IntItem result = (IntItem)L1AHelper.requestWordRegister(ec, JvmType.INT, false); final GPR resultr = result.getRegister(); // Get flags os.writeMOV(BITS32, resultr, r, ObjectLayout.FLAGS_SLOT * slotSize); os.writeAND(resultr, ObjectFlags.STATUS_FINALIZED); obj.release(ec); vstack.push(result); } break; case ATOMICADD: case ATOMICAND: case ATOMICOR: case ATOMICSUB: { if (Vm.VerifyAssertions) Vm._assert(!isstatic); final RefItem value = vstack.popRef(); final RefItem addr = vstack.popRef(); value.load(ec); addr.load(ec); final X86Register.GPR valuer = (X86Register.GPR)value.getRegister(); final X86Register.GPR r = (X86Register.GPR)addr.getRegister(); os.writePrefix(X86Constants.LOCK_PREFIX); os.writeArithOp(methodCodeToOperation(mcode), r, 0, valuer); value.release(ec); addr.release(ec); } break; case GETCURRENTFRAME: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final WordItem result = L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, false); final GPR r = result.getRegister(); os.writeMOV(helper.ADDRSIZE, r, helper.BP); vstack.push(result); } break; case GETTIMESTAMP: { if (Vm.VerifyAssertions) Vm._assert(isstatic); if (os.isCode32()) { final DoubleWordItem result = L1AHelper.requestDoubleWordRegisters(ec, JvmType.LONG, X86Register.EAX, X86Register.EDX); os.writeRDTSC(); vstack.push(result); } else { final DoubleWordItem result = L1AHelper.requestDoubleWordRegister(ec, JvmType.LONG, X86Register.RAX); L1AHelper.requestRegister(ec, X86Register.RDX); os.writeRDTSC(); // Move MSB to upper 32-bit of RDX os.writeSHL(X86Register.RDX, 32); // RAX is zero extended by RDTSC, so an OR of RAX,RDX will combine // the upper 32-bits of RDX and the lower 32-bits of RAX. os.writeOR(X86Register.RAX, X86Register.RDX); // Now free RDX L1AHelper.releaseRegister(ec, X86Register.RDX); vstack.push(result); } } break; case INTBITSTOFLOAT: case FLOATTORAWINTBITS: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final WordItem v = (WordItem)vstack.pop(); v.load(ec); final X86Register.GPR r = v.getRegister(); v.release(ec); final int resultType = (mcode == INTBITSTOFLOAT) ? JvmType.FLOAT : JvmType.INT; vstack.push(L1AHelper.requestWordRegister(ec, resultType, r)); } break; case LONGBITSTODOUBLE: case DOUBLETORAWLONGBITS: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final DoubleWordItem v = (DoubleWordItem)vstack.pop(); v.load(ec); final int resultType = (mcode == LONGBITSTODOUBLE) ? JvmType.DOUBLE : JvmType.LONG; if (os.isCode32()) { final X86Register.GPR lsb = v.getLsbRegister(ec); final X86Register.GPR msb = v.getMsbRegister(ec); v.release(ec); vstack.push(L1AHelper.requestDoubleWordRegisters(ec, resultType, lsb, msb)); } else { final GPR64 vreg = v.getRegister(ec); v.release(ec); vstack.push(L1AHelper.requestDoubleWordRegister(ec, resultType, vreg)); } } break; case BREAKPOINT: { if (Vm.VerifyAssertions) Vm._assert(isstatic); os.writeINT(3); } break; case CURRENTPROCESSOR: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final RefItem item = (RefItem)L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, false); final int offset = ec.getContext().getVmProcessorMeField().getOffset(); if (os.isCode32()) { os.writePrefix(X86Constants.FS_PREFIX); os.writeMOV(item.getRegister(), offset); } else { os.writeMOV(BITS64, item.getRegister(), X86Register.R12, offset); } vstack.push(item); } break; case GETSHAREDSTATICSFIELDADDRESS: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final IntItem index = (IntItem)vstack.pop(); index.load(ec); final RefItem item = (RefItem)L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, false); final GPR itemReg = item.getRegister(); final int offset = ec.getContext().getVmProcessorSharedStaticsTable().getOffset(); // Load table if (os.isCode32()) { os.writePrefix(X86Constants.FS_PREFIX); os.writeMOV(itemReg, offset); } else { os.writeMOV(BITS64, itemReg, X86CompilerConstants.PROCESSOR64, offset); } os.writeLEA(itemReg, itemReg, index.getRegister(), os.getWordSize(), VmArray.DATA_OFFSET * os.getWordSize()); index.release(ec); vstack.push(item); } break; case GETISOLATEDSTATICSFIELDADDRESS: { if (Vm.VerifyAssertions) Vm._assert(isstatic); final IntItem index = (IntItem)vstack.pop(); index.load(ec); final RefItem item = (RefItem)L1AHelper.requestWordRegister(ec, JvmType.REFERENCE, false); final GPR itemReg = item.getRegister(); final int offset = ec.getContext().getVmProcessorIsolatedStaticsTable().getOffset(); // Load table if (os.isCode32()) { os.writePrefix(X86Constants.FS_PREFIX); os.writeMOV(itemReg, offset); } else { os.writeMOV(BITS64, itemReg, X86CompilerConstants.PROCESSOR64, offset); } os.writeLEA(itemReg, itemReg, index.getRegister(), os.getWordSize(), VmArray.DATA_OFFSET * os.getWordSize()); index.release(ec); vstack.push(item); } break; case ISRUNNINGJNODE: { if (Vm.VerifyAssertions) Vm._assert(isstatic); vstack.push(ifac.createIConst(ec, 1)); } break; // xyzArray classes case ARR_CREATE: { if (os.isCode32()) { bcv.visit_newarray(10); // int[] } else { bcv.visit_newarray(11); // long[] } } break; case ARR_GET: { bcv.waload(JvmType.REFERENCE); } break; case ARR_SET: { bcv.wastore(JvmType.REFERENCE); } break; case ARR_LENGTH: { bcv.visit_arraylength(); } break; default: throw new InternalError("Unknown method code for method " + method); } } |
public DoubleWordItem createReg(EmitterContext ec, int jvmType, X86Register.GPR lsb, X86Register.GPR msb) { if (!ec.getStream().isCode32()) { throw new IllegalModeException("Only supported in 32-bit mode"); } final DoubleWordItem item = (DoubleWordItem) getOrCreate(jvmType); item.initialize(ec, Item.Kind.GPR, 0, lsb, msb, null, null); | public WordItem createReg(EmitterContext ec, int jvmType, X86Register reg) { final WordItem item = (WordItem) getOrCreate(jvmType); item.initialize(ec, Item.Kind.GPR, reg, 0); | public DoubleWordItem createReg(EmitterContext ec, int jvmType, X86Register.GPR lsb, X86Register.GPR msb) { if (!ec.getStream().isCode32()) { throw new IllegalModeException("Only supported in 32-bit mode"); } final DoubleWordItem item = (DoubleWordItem) getOrCreate(jvmType); item.initialize(ec, Item.Kind.GPR, 0, lsb, msb, null, null); return item; } |
public boolean isIgnoringElementContentWhitespace() { return whitespace; } | public boolean isIgnoringElementContentWhitespace() { return ignoringElementContentWhitespace; } | public boolean isIgnoringElementContentWhitespace() { return whitespace; } // isIgnoringElementContentWhitespace() |
public boolean isIgnoringComments() { return ignoreComments; } | public boolean isIgnoringComments() { return ignoringComments; } | public boolean isIgnoringComments() { return ignoreComments; } // isIgnoringComments() |
public boolean isExpandEntityReferences() { return expandEntityRef; } | public boolean isExpandEntityReferences() { return expandEntityReferences; } | public boolean isExpandEntityReferences() { return expandEntityRef; } // isExpandEntityReferences() |
public ParserConfigurationException(String message) { super(message); } | public ParserConfigurationException() { super(); } | public ParserConfigurationException(String message) { super(message); } // ParserConfigurationException() |
while (ncomponents > 0) remove(0); | for ( int index = 0; index < ncomponents; index++) { Component r = component[index]; ComponentListener[] list = r.getComponentListeners(); for (int j = 0; j < list.length; j++) r.removeComponentListener(list[j]); r.removeNotify(); if (layoutMgr != null) layoutMgr.removeLayoutComponent(r); r.parent = null; if (isShowing ()) { ContainerEvent ce = new ContainerEvent(this, ContainerEvent.COMPONENT_REMOVED, r); getToolkit().getSystemEventQueue().postEvent(ce); } } invalidate(); ncomponents = 0; | public void removeAll() { synchronized (getTreeLock ()) { while (ncomponents > 0) remove(0); } } |
Toolkit.getDefaultToolkit().globalDispatchEvent(e); | void dispatchEventImpl(AWTEvent e) { // This boolean tells us not to process focus events when the focus // opposite component is the same as the focus component. boolean ignoreFocus = (e instanceof FocusEvent && ((FocusEvent)e).getComponent() == ((FocusEvent)e).getOppositeComponent()); if (eventTypeEnabled (e.id)) { // the trick we use to communicate between dispatch and redispatch // is to have KeyboardFocusManager.redispatch synchronize on the // object itself. we then do not redispatch to KeyboardFocusManager // if we are already holding the lock. if (! Thread.holdsLock(e)) { switch (e.id) { case WindowEvent.WINDOW_GAINED_FOCUS: case WindowEvent.WINDOW_LOST_FOCUS: case KeyEvent.KEY_PRESSED: case KeyEvent.KEY_RELEASED: case KeyEvent.KEY_TYPED: case FocusEvent.FOCUS_GAINED: case FocusEvent.FOCUS_LOST: if (KeyboardFocusManager .getCurrentKeyboardFocusManager() .dispatchEvent(e)) return; case MouseEvent.MOUSE_PRESSED: if (isLightweight()) requestFocus(); break; } } if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE && !ignoreFocus) processEvent(e); } if (peer != null) peer.handleEvent(e); } |
|
return new Dimension(width, height); | prefSize = minimumSize(); | public Dimension preferredSize() { if (prefSize == null) if (peer == null) return new Dimension(width, height); else prefSize = peer.getPreferredSize(); return prefSize; } |
} | public Dimension preferredSize() { if (prefSize == null) if (peer == null) return new Dimension(width, height); else prefSize = peer.getPreferredSize(); return prefSize; } |
|
Shape clip = getClip(); if (clip == null) return true; | public boolean hitClip(int x, int y, int width, int height) { return getClip().intersects(x, y, width, height); } |
|
public Graphics create(int x, int y, int width, int height) { Graphics g = create(); g.translate(x, y); g.clipRect(0, 0, width, height); return(g); } | public abstract Graphics create(); | public Graphics create(int x, int y, int width, int height) { Graphics g = create(); g.translate(x, y); // FIXME: I'm not sure if this will work. Are the old clip rect bounds // translated above? g.clipRect(0, 0, width, height); return(g); } |
if (osc.isEnum()) { realOutput.writeByte(TC_ENUM); writeObject(osc); assignNewHandle(obj); writeObject(((Enum) obj).name()); break; } | public final void writeObject(Object obj) throws IOException { if (useSubclassMethod) { if (dump) dumpElementln ("WRITE OVERRIDE: " + obj); writeObjectOverride(obj); return; } if (dump) dumpElementln ("WRITE: " + obj); depth += 2; boolean was_serializing = isSerializing; boolean old_mode = setBlockDataMode(false); try { isSerializing = true; boolean replaceDone = false; Object replacedObject = null; while (true) { if (obj == null) { realOutput.writeByte(TC_NULL); break; } Integer handle = findHandle(obj); if (handle != null) { realOutput.writeByte(TC_REFERENCE); realOutput.writeInt(handle.intValue()); break; } if (obj instanceof Class) { Class cl = (Class)obj; ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject(cl); realOutput.writeByte(TC_CLASS); if (!osc.isProxyClass) { writeObject (osc); } else { realOutput.writeByte(TC_PROXYCLASSDESC); Class[] intfs = cl.getInterfaces(); realOutput.writeInt(intfs.length); for (int i = 0; i < intfs.length; i++) realOutput.writeUTF(intfs[i].getName()); boolean oldmode = setBlockDataMode(true); annotateProxyClass(cl); setBlockDataMode(oldmode); realOutput.writeByte(TC_ENDBLOCKDATA); writeObject(osc.getSuper()); } assignNewHandle(obj); break; } if (obj instanceof ObjectStreamClass) { writeClassDescriptor((ObjectStreamClass) obj); break; } Class clazz = obj.getClass(); ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject(clazz); if (osc == null) throw new NotSerializableException(clazz.getName()); if ((replacementEnabled || obj instanceof Serializable) && ! replaceDone) { replacedObject = obj; if (obj instanceof Serializable) { try { Method m = osc.writeReplaceMethod; if (m != null) obj = m.invoke(obj, new Object[0]); } catch (IllegalAccessException ignore) { } catch (InvocationTargetException ignore) { } } if (replacementEnabled) obj = replaceObject(obj); replaceDone = true; continue; } if (obj instanceof String) { realOutput.writeByte(TC_STRING); assignNewHandle(obj); realOutput.writeUTF((String)obj); break; } if (clazz.isArray ()) { realOutput.writeByte(TC_ARRAY); writeObject(osc); assignNewHandle(obj); writeArraySizeAndElements(obj, clazz.getComponentType()); break; } realOutput.writeByte(TC_OBJECT); writeObject(osc); if (replaceDone) assignNewHandle(replacedObject); else assignNewHandle(obj); if (obj instanceof Externalizable) { if (protocolVersion == PROTOCOL_VERSION_2) setBlockDataMode(true); ((Externalizable)obj).writeExternal(this); if (protocolVersion == PROTOCOL_VERSION_2) { setBlockDataMode(false); realOutput.writeByte(TC_ENDBLOCKDATA); } break; } if (obj instanceof Serializable) { Object prevObject = this.currentObject; ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass; currentObject = obj; ObjectStreamClass[] hierarchy = ObjectStreamClass.getObjectStreamClasses(clazz); for (int i = 0; i < hierarchy.length; i++) { currentObjectStreamClass = hierarchy[i]; fieldsAlreadyWritten = false; if (currentObjectStreamClass.hasWriteMethod()) { if (dump) dumpElementln ("WRITE METHOD CALLED FOR: " + obj); setBlockDataMode(true); callWriteMethod(obj, currentObjectStreamClass); setBlockDataMode(false); realOutput.writeByte(TC_ENDBLOCKDATA); if (dump) dumpElementln ("WRITE ENDBLOCKDATA FOR: " + obj); } else { if (dump) dumpElementln ("WRITE FIELDS CALLED FOR: " + obj); writeFields(obj, currentObjectStreamClass); } } this.currentObject = prevObject; this.currentObjectStreamClass = prevObjectStreamClass; currentPutField = null; break; } throw new NotSerializableException(clazz.getName() + " in " + obj.getClass()); } // end pseudo-loop } catch (ObjectStreamException ose) { // Rethrow these are fatal. throw ose; } catch (IOException e) { realOutput.writeByte(TC_EXCEPTION); reset(true); setBlockDataMode(false); try { if (DEBUG) { e.printStackTrace(System.out); } writeObject(e); } catch (IOException ioe) { StreamCorruptedException ex = new StreamCorruptedException (ioe + " thrown while exception was being written to stream."); if (DEBUG) { ex.printStackTrace(System.out); } throw ex; } reset (true); } finally { isSerializing = was_serializing; setBlockDataMode(old_mode); depth -= 2; if (dump) dumpElementln ("END: " + obj); } } |
|
public UIDefaults getDefaults() { if (LAF_defaults == null) LAF_defaults = new BasicDefaults(); return LAF_defaults; } | public UIDefaults getDefaults() { if (LAF_defaults == null) LAF_defaults = super.getDefaults(); return LAF_defaults; } | public UIDefaults getDefaults() { if (LAF_defaults == null) LAF_defaults = new BasicDefaults(); // Returns the default values for this look and feel. return LAF_defaults; } |
public JIFSFile(String name) { this.name = name; | public JIFSFile() { refresh(); | public JIFSFile(String name) { this.name = name; } |
return null; | MARSHAL m = new MARSHAL("Unable to open a socket at " + ior.Internet.host + ":" + ior.Internet.port ); m.initCause(io_ex); throw m; | public synchronized binaryReply submit() { gnu.CORBA.GIOP.MessageHeader header = new gnu.CORBA.GIOP.MessageHeader(); header.setBigEndian(Big_endian); // The byte order will be Big Endian by default. header.message_type = gnu.CORBA.GIOP.MessageHeader.REQUEST; header.version = useVersion(ior.Internet.version); RequestHeader rh = header.create_request_header(); rh.object_key = ior.key; rh.operation = m_operation; // Prepare the submission. cdrBufOutput request_part = new cdrBufOutput(); request_part.setOffset(header.getHeaderSize()); request_part.setVersion(header.version); request_part.setCodeSet(cxCodeSet.negotiate(ior.CodeSets)); request_part.setOrb(orb); request_part.setBigEndian(header.isBigEndian()); // This also sets the stream encoding to the encoding, specified // in the header. rh.write(request_part); if (m_args != null && m_args.count() > 0) { write_parameters(header, request_part); if (m_parameter_buffer != null) throw new BAD_INV_ORDER("Please either add parameters or " + "write them into stream, but not both " + "at once." ); } if (m_parameter_buffer != null) { write_parameter_buffer(header, request_part); } // Now the message size is available. header.message_size = request_part.buffer.size(); Socket socket = null; java.lang.Object key = ior.Internet.host+":"+ior.Internet.port; synchronized (SocketRepository.class) { socket = SocketRepository.get_socket(key); } try { long pause = PAUSE_INITIAL; if (socket == null) { // The BindException may be thrown under very heavy parallel // load. For some time, just wait, exceptiong the socket to free. Open: for (int i = 0; i < PAUSE_STEPS; i++) { try { socket = new Socket(ior.Internet.host, ior.Internet.port); break Open; } catch (BindException ex) { try { // Expecting to free a socket via finaliser. System.gc(); Thread.sleep(pause); pause = pause * 2; if (pause > PAUSE_MAX) pause = PAUSE_MAX; } catch (InterruptedException iex) { } } } } if (socket == null) throw new NO_RESOURCES(ior.Internet.host + ":" + ior.Internet.port + " in use" ); socket.setKeepAlive(true); OutputStream socketOutput = socket.getOutputStream(); // Write the message header. header.write(socketOutput); // Write the request header and parameters (if present). request_part.buffer.writeTo(socketOutput); socketOutput.flush(); if (!socket.isClosed()) { MessageHeader response_header = new MessageHeader(); InputStream socketInput = socket.getInputStream(); response_header.read(socketInput); byte[] r = new byte[ response_header.message_size ]; int n = 0; reading: while (n < r.length) { n += socketInput.read(r, n, r.length - n); } return new binaryReply(orb, response_header, r); } else return EMPTY; } catch (IOException io_ex) { return null; } finally { try { if (socket != null && !socket.isClosed()) { socket.setSoTimeout(Functional_ORB.TANDEM_REQUESTS); SocketRepository.put_socket(key, socket ); } } catch (IOException scx) { InternalError ierr = new InternalError(); ierr.initCause(scx); throw ierr; } } } |
public Unexpected(Exception why) | public Unexpected(String msg, Exception why) | public Unexpected(Exception why) { super(SHARED_MESSAGE); if (why != null) initCause(why); } |
super(SHARED_MESSAGE); | super(msg + ". " + SHARED_MESSAGE); | public Unexpected(Exception why) { super(SHARED_MESSAGE); if (why != null) initCause(why); } |
public void add(NamedValue value) | public NamedValue add(int a_flags) | public void add(NamedValue value) { list.add(value); } |
list.add(value); | return add_value(null, new gnuAny(), a_flags); | public void add(NamedValue value) { list.add(value); } |
public static void error(Exception why) | public static void error(String msg, Exception why) | public static void error(Exception why) { throw new Unexpected(why); } |
throw new Unexpected(why); | throw new Unexpected(msg, why); | public static void error(Exception why) { throw new Unexpected(why); } |
public abstract void exception(Exception except); | public abstract Exception exception(); | public abstract void exception(Exception except); |
public UnknownUserException(Any an_exception) | public UnknownUserException() | public UnknownUserException(Any an_exception) { except = an_exception; } |
except = an_exception; | public UnknownUserException(Any an_exception) { except = an_exception; } |
|
DataInputStream din = new DataInputStream(istream); | public void read(java.io.InputStream istream) throws MARSHAL { try { DataInputStream din = new DataInputStream(istream); byte[] xMagic = new byte[ MAGIC.length ]; din.read(xMagic); if (!Arrays.equals(xMagic, MAGIC)) throw new MARSHAL("Not a GIOP message"); version = Version.read_version(din); flags = (byte) din.read(); /** TODO implement support for the little endian. */ if (!isBigEndian()) throw new MARSHAL("Little endian unsupported."); message_type = (byte) din.read(); message_size = din.readInt(); } catch (IOException ex) { throw new MARSHAL(ex.toString()); } } |
|
din.read(xMagic); | istream.read(xMagic); | public void read(java.io.InputStream istream) throws MARSHAL { try { DataInputStream din = new DataInputStream(istream); byte[] xMagic = new byte[ MAGIC.length ]; din.read(xMagic); if (!Arrays.equals(xMagic, MAGIC)) throw new MARSHAL("Not a GIOP message"); version = Version.read_version(din); flags = (byte) din.read(); /** TODO implement support for the little endian. */ if (!isBigEndian()) throw new MARSHAL("Little endian unsupported."); message_type = (byte) din.read(); message_size = din.readInt(); } catch (IOException ex) { throw new MARSHAL(ex.toString()); } } |
version = Version.read_version(din); | version = Version.read_version(istream); | public void read(java.io.InputStream istream) throws MARSHAL { try { DataInputStream din = new DataInputStream(istream); byte[] xMagic = new byte[ MAGIC.length ]; din.read(xMagic); if (!Arrays.equals(xMagic, MAGIC)) throw new MARSHAL("Not a GIOP message"); version = Version.read_version(din); flags = (byte) din.read(); /** TODO implement support for the little endian. */ if (!isBigEndian()) throw new MARSHAL("Little endian unsupported."); message_type = (byte) din.read(); message_size = din.readInt(); } catch (IOException ex) { throw new MARSHAL(ex.toString()); } } |
flags = (byte) din.read(); | abstractDataInputStream din; | public void read(java.io.InputStream istream) throws MARSHAL { try { DataInputStream din = new DataInputStream(istream); byte[] xMagic = new byte[ MAGIC.length ]; din.read(xMagic); if (!Arrays.equals(xMagic, MAGIC)) throw new MARSHAL("Not a GIOP message"); version = Version.read_version(din); flags = (byte) din.read(); /** TODO implement support for the little endian. */ if (!isBigEndian()) throw new MARSHAL("Little endian unsupported."); message_type = (byte) din.read(); message_size = din.readInt(); } catch (IOException ex) { throw new MARSHAL(ex.toString()); } } |
if (!isBigEndian()) throw new MARSHAL("Little endian unsupported."); | flags = (byte) istream.read(); if (isBigEndian()) din = new BigEndianInputStream(istream); else din = new LittleEndianInputStream(istream); | public void read(java.io.InputStream istream) throws MARSHAL { try { DataInputStream din = new DataInputStream(istream); byte[] xMagic = new byte[ MAGIC.length ]; din.read(xMagic); if (!Arrays.equals(xMagic, MAGIC)) throw new MARSHAL("Not a GIOP message"); version = Version.read_version(din); flags = (byte) din.read(); /** TODO implement support for the little endian. */ if (!isBigEndian()) throw new MARSHAL("Little endian unsupported."); message_type = (byte) din.read(); message_size = din.readInt(); } catch (IOException ex) { throw new MARSHAL(ex.toString()); } } |
throw new MARSHAL(ex.toString()); | MARSHAL t = new MARSHAL(); t.initCause(ex); throw t; | public void read(java.io.InputStream istream) throws MARSHAL { try { DataInputStream din = new DataInputStream(istream); byte[] xMagic = new byte[ MAGIC.length ]; din.read(xMagic); if (!Arrays.equals(xMagic, MAGIC)) throw new MARSHAL("Not a GIOP message"); version = Version.read_version(din); flags = (byte) din.read(); /** TODO implement support for the little endian. */ if (!isBigEndian()) throw new MARSHAL("Little endian unsupported."); message_type = (byte) din.read(); message_size = din.readInt(); } catch (IOException ex) { throw new MARSHAL(ex.toString()); } } |
res.put("gnu.java.io.encoding_scheme_alias.UTF-16LE", "UTF16LE"); res.put("gnu.java.io.encoding_scheme_alias.UTF-16BE", "UTF16BE"); | public static Properties getInitProperties() { final String arch; final Vm vm = Vm.getVm(); arch = vm.getArch().getName(); final Properties res = new Properties(); // Java properties res.put("java.version", "1.1.0"); res.put("java.vendor", "JNode.org"); res.put("java.vendor.url", "http://jnode.org"); res.put("java.home", "/"); res.put("java.vm.specification.version", "1.4"); res.put("java.vm.specification.vendor", "JNode.org"); res.put("java.vm.specification.name", "jnode"); res.put("java.vm.version", vm.getVersion()); res.put("java.vm.vendor", "JNode.org"); res.put("java.vm.name", "JNode"); res.put("java.class.version", "1.1"); res.put("java.class.path", ""); res.put("java.library.path", ""); res.put("java.io.tmpdir", "/tmp"); res.put("java.compiler", "Internal"); res.put("java.ext.dirs", ""); res.put("os.name", "JNode"); res.put("os.arch", arch); res.put("os.version", vm.getVersion()); res.put("file.separator", "/"); res.put("path.separator", ":"); res.put("line.separator", "\n"); res.put("user.name", "System"); res.put("user.home", "/"); res.put("user.dir", "/"); // GNU properties res.put("gnu.java.io.encoding_scheme_alias.US-ASCII", "ISO8859-1"); return res; } |
|
helper.copy(objectPtr, ObjectReference.fromObject(newObj).toAddress(), size); | helper.copy(objectPtr, ObjectReference.fromObject(newObj).toAddress(), Extent.fromIntZeroExtend(size)); | public final Object clone(Cloneable object) { testInited(); final VmClassType objectClass = VmMagic.getObjectType(object); final Address objectPtr = ObjectReference.fromObject(object).toAddress(); final int size; if (objectClass.isArray()) { final int slotSize = Unsafe.getCurrentProcessor().getArchitecture().getReferenceSize(); final VmArrayClass arrayClass = (VmArrayClass) objectClass; final int length = objectPtr.loadInt(Offset.fromIntSignExtend(VmArray.LENGTH_OFFSET * slotSize)); final int elemSize = arrayClass.getComponentType().getTypeSize(); size = (VmArray.DATA_OFFSET * slotSize) * (length * elemSize); } else { final VmNormalClass normalClass = (VmNormalClass) objectClass; size = normalClass.getObjectSize(); } final Object newObj = allocObject(objectClass, size); helper.copy(objectPtr, ObjectReference.fromObject(newObj).toAddress(), size); return newObj; } |
return (VmMethod)Unsafe.getObject(sf, getMethodOffset(sf)); | final Object obj = Unsafe.getObject(sf, getMethodOffset(sf)); if (obj instanceof VmMethod) { return (VmMethod)obj; } else if (obj == null) { return null; } else { Unsafe.debug("Method on stacktrace is not instanceof VmMethod but "); Unsafe.debug(obj.getClass().getName()); Unsafe.die("Fatal stack error"); return null; } | final VmMethod getMethod(Address sf) { return (VmMethod)Unsafe.getObject(sf, getMethodOffset(sf)); } |
public Exception(String s) | public Exception() | public Exception(String s) { super(s); } |
super(s); | public Exception(String s) { super(s); } |
|
entries = Collections.EMPTY_MAP; entryNames = Collections.EMPTY_LIST; | entries = Collections.emptyMap(); entryNames = Collections.emptyList(); | private FSEntryTable() { entries = Collections.EMPTY_MAP; entryNames = Collections.EMPTY_LIST; } |
throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); | throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); | public final void setPrefix(String prefix) { if (readonly) { throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); } if (prefix == null) { name = localName; return; } else if (namespace == null) { throw new DomEx(DomEx.NAMESPACE_ERR, "can't set prefix, node has no namespace URI", this, 0); } DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion())); if (prefix.indexOf (':') != -1) { throw new DomEx(DomEx.NAMESPACE_ERR, "illegal prefix " + prefix, this, 0); } if (XMLConstants.XML_NS_PREFIX.equals(prefix) && !XMLConstants.XML_NS_URI.equals(namespace)) { throw new DomEx(DomEx.NAMESPACE_ERR, "xml namespace is always " + XMLConstants.XML_NS_URI, this, 0); } if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { if (namespace != null || getNodeType() != ATTRIBUTE_NODE) { throw new DomEx(DomEx.NAMESPACE_ERR, "xmlns attribute prefix is reserved", this, 0); } } else if (getNodeType () == ATTRIBUTE_NODE && (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || name.startsWith("xmlns:"))) { throw new DomEx(DomEx.NAMESPACE_ERR, "namespace declarations can't change names", this, 0); } this.prefix = prefix.intern(); } |
throw new DomEx(DomEx.NAMESPACE_ERR, | throw new DomDOMException(DOMException.NAMESPACE_ERR, | public final void setPrefix(String prefix) { if (readonly) { throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); } if (prefix == null) { name = localName; return; } else if (namespace == null) { throw new DomEx(DomEx.NAMESPACE_ERR, "can't set prefix, node has no namespace URI", this, 0); } DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion())); if (prefix.indexOf (':') != -1) { throw new DomEx(DomEx.NAMESPACE_ERR, "illegal prefix " + prefix, this, 0); } if (XMLConstants.XML_NS_PREFIX.equals(prefix) && !XMLConstants.XML_NS_URI.equals(namespace)) { throw new DomEx(DomEx.NAMESPACE_ERR, "xml namespace is always " + XMLConstants.XML_NS_URI, this, 0); } if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { if (namespace != null || getNodeType() != ATTRIBUTE_NODE) { throw new DomEx(DomEx.NAMESPACE_ERR, "xmlns attribute prefix is reserved", this, 0); } } else if (getNodeType () == ATTRIBUTE_NODE && (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || name.startsWith("xmlns:"))) { throw new DomEx(DomEx.NAMESPACE_ERR, "namespace declarations can't change names", this, 0); } this.prefix = prefix.intern(); } |
throw new DomEx(DomEx.NAMESPACE_ERR, "xmlns attribute prefix is reserved", this, 0); | throw new DomDOMException(DOMException.NAMESPACE_ERR, "xmlns attribute prefix is reserved", this, 0); | public final void setPrefix(String prefix) { if (readonly) { throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); } if (prefix == null) { name = localName; return; } else if (namespace == null) { throw new DomEx(DomEx.NAMESPACE_ERR, "can't set prefix, node has no namespace URI", this, 0); } DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion())); if (prefix.indexOf (':') != -1) { throw new DomEx(DomEx.NAMESPACE_ERR, "illegal prefix " + prefix, this, 0); } if (XMLConstants.XML_NS_PREFIX.equals(prefix) && !XMLConstants.XML_NS_URI.equals(namespace)) { throw new DomEx(DomEx.NAMESPACE_ERR, "xml namespace is always " + XMLConstants.XML_NS_URI, this, 0); } if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { if (namespace != null || getNodeType() != ATTRIBUTE_NODE) { throw new DomEx(DomEx.NAMESPACE_ERR, "xmlns attribute prefix is reserved", this, 0); } } else if (getNodeType () == ATTRIBUTE_NODE && (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || name.startsWith("xmlns:"))) { throw new DomEx(DomEx.NAMESPACE_ERR, "namespace declarations can't change names", this, 0); } this.prefix = prefix.intern(); } |
throw new DomEx(DomEx.NAMESPACE_ERR, "namespace declarations can't change names", this, 0); | throw new DomDOMException(DOMException.NAMESPACE_ERR, "namespace declarations can't change names", this, 0); | public final void setPrefix(String prefix) { if (readonly) { throw new DomEx(DomEx.NO_MODIFICATION_ALLOWED_ERR); } if (prefix == null) { name = localName; return; } else if (namespace == null) { throw new DomEx(DomEx.NAMESPACE_ERR, "can't set prefix, node has no namespace URI", this, 0); } DomDocument.checkName(prefix, "1.1".equals(owner.getXmlVersion())); if (prefix.indexOf (':') != -1) { throw new DomEx(DomEx.NAMESPACE_ERR, "illegal prefix " + prefix, this, 0); } if (XMLConstants.XML_NS_PREFIX.equals(prefix) && !XMLConstants.XML_NS_URI.equals(namespace)) { throw new DomEx(DomEx.NAMESPACE_ERR, "xml namespace is always " + XMLConstants.XML_NS_URI, this, 0); } if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { if (namespace != null || getNodeType() != ATTRIBUTE_NODE) { throw new DomEx(DomEx.NAMESPACE_ERR, "xmlns attribute prefix is reserved", this, 0); } } else if (getNodeType () == ATTRIBUTE_NODE && (XMLConstants.XMLNS_ATTRIBUTE.equals(name) || name.startsWith("xmlns:"))) { throw new DomEx(DomEx.NAMESPACE_ERR, "namespace declarations can't change names", this, 0); } this.prefix = prefix.intern(); } |
slider.setOpaque(true); | protected void installDefaults(JSlider slider) { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); slider.setForeground(defaults.getColor("Slider.foreground")); slider.setBackground(defaults.getColor("Slider.background")); shadowColor = defaults.getColor("Slider.shadow"); highlightColor = defaults.getColor("Slider.highlight"); focusColor = defaults.getColor("Slider.focus"); slider.setBorder(defaults.getBorder("Slider.border")); thumbHeight = defaults.getInt("Slider.thumbHeight"); thumbWidth = defaults.getInt("Slider.thumbWidth"); tickHeight = defaults.getInt("Slider.tickHeight"); focusInsets = defaults.getInsets("Slider.focusInsets"); } |
|
public void drawPolygon(Polygon polygon) { drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); } | public abstract void drawPolygon(int xPoints[], int yPoints[], int npoints); | public void drawPolygon(Polygon polygon) { drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); } |
htmlAttributeSet attributes = gnu.getAttributes(); | SimpleAttributeSet attributes = gnu.getAttributes(); | protected final void handleStartTag(TagElement tag) { parser.handleStartTag(tag); htmlAttributeSet attributes = gnu.getAttributes(); if (tag.fictional()) attributes.addAttribute(HTMLEditorKit.ParserCallback.IMPLIED, Boolean.TRUE ); callBack.handleStartTag(tag.getHTMLTag(), attributes, hTag.where.startPosition ); } |
public ClassNotFoundException(String s, Throwable ex) | public ClassNotFoundException() | public ClassNotFoundException(String s, Throwable ex) { super(s, ex); this.ex = ex; } |
super(s, ex); this.ex = ex; | this(null, null); | public ClassNotFoundException(String s, Throwable ex) { super(s, ex); this.ex = ex; } |
if (comp == rootPane) | if (!initStageDone) | protected void addImpl(Component comp, Object constraints, int index) { // If we're adding the rootPane (initialization stages) use super.add. // Otherwise pass the add onto the content pane. if (comp == rootPane) super.addImpl(comp, constraints, index); else { if (isRootPaneCheckingEnabled()) throw new Error("Do not use add() on JApplet directly. Use " + "getContentPane().add() instead"); getContentPane().add(comp, constraints, index); } } |
public Container getContentPane(); | Container getContentPane(); | public Container getContentPane(); |
public Component getGlassPane(); | Component getGlassPane(); | public Component getGlassPane(); |
public JLayeredPane getLayeredPane(); | JLayeredPane getLayeredPane(); | public JLayeredPane getLayeredPane(); |
public JRootPane getRootPane(); | JRootPane getRootPane(); | public JRootPane getRootPane(); |
public void setContentPane(Container contentPane); | void setContentPane(Container contentPane); | public void setContentPane(Container contentPane); |
public void setGlassPane(Component glassPane); | void setGlassPane(Component glassPane); | public void setGlassPane(Component glassPane); |
public void setLayeredPane(JLayeredPane layeredPane); | void setLayeredPane(JLayeredPane layeredPane); | public void setLayeredPane(JLayeredPane layeredPane); |
public TreeMap(Comparator<? super K> c) | public TreeMap() | public TreeMap(Comparator<? super K> c) { comparator = c; fabricateTree(0); } |
comparator = c; fabricateTree(0); | this((Comparator) null); | public TreeMap(Comparator<? super K> c) { comparator = c; fabricateTree(0); } |
maximumIntegerDigits = 309; | maximumIntegerDigits = MAXIMUM_INTEGER_DIGITS; | private final void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms) { // Initialize to the state the parser expects. negativePrefix = ""; negativeSuffix = ""; positivePrefix = ""; positiveSuffix = ""; decimalSeparatorAlwaysShown = false; groupingSize = 0; minExponentDigits = 0; multiplier = 1; useExponentialNotation = false; groupingUsed = false; maximumFractionDigits = 0; maximumIntegerDigits = 309; minimumFractionDigits = 0; minimumIntegerDigits = 1; StringBuffer buf = new StringBuffer(); String patChars = patternChars(syms); int max = pattern.length(); int index = scanFix(pattern, 0, buf, patChars, syms, false); positivePrefix = buf.toString(); index = scanFormat(pattern, index, patChars, syms, true); index = scanFix(pattern, index, buf, patChars, syms, true); positiveSuffix = buf.toString(); if (index == pattern.length()) { // No negative info. negativePrefix = null; negativeSuffix = null; } else { if (pattern.charAt(index) != syms.getPatternSeparator()) throw new IllegalArgumentException("separator character " + "expected - index: " + index); index = scanFix(pattern, index + 1, buf, patChars, syms, false); negativePrefix = buf.toString(); // We parse the negative format for errors but we don't let // it side-effect this object. index = scanFormat(pattern, index, patChars, syms, false); index = scanFix(pattern, index, buf, patChars, syms, true); negativeSuffix = buf.toString(); if (index != pattern.length()) throw new IllegalArgumentException("end of pattern expected " + "- index: " + index); } } |
StringBuffer buf = new StringBuffer(); String patChars = patternChars(syms); | AttributedFormatBuffer buf = new AttributedFormatBuffer (); String patChars = patternChars (syms); | private final void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms) { // Initialize to the state the parser expects. negativePrefix = ""; negativeSuffix = ""; positivePrefix = ""; positiveSuffix = ""; decimalSeparatorAlwaysShown = false; groupingSize = 0; minExponentDigits = 0; multiplier = 1; useExponentialNotation = false; groupingUsed = false; maximumFractionDigits = 0; maximumIntegerDigits = 309; minimumFractionDigits = 0; minimumIntegerDigits = 1; StringBuffer buf = new StringBuffer(); String patChars = patternChars(syms); int max = pattern.length(); int index = scanFix(pattern, 0, buf, patChars, syms, false); positivePrefix = buf.toString(); index = scanFormat(pattern, index, patChars, syms, true); index = scanFix(pattern, index, buf, patChars, syms, true); positiveSuffix = buf.toString(); if (index == pattern.length()) { // No negative info. negativePrefix = null; negativeSuffix = null; } else { if (pattern.charAt(index) != syms.getPatternSeparator()) throw new IllegalArgumentException("separator character " + "expected - index: " + index); index = scanFix(pattern, index + 1, buf, patChars, syms, false); negativePrefix = buf.toString(); // We parse the negative format for errors but we don't let // it side-effect this object. index = scanFormat(pattern, index, patChars, syms, false); index = scanFix(pattern, index, buf, patChars, syms, true); negativeSuffix = buf.toString(); if (index != pattern.length()) throw new IllegalArgumentException("end of pattern expected " + "- index: " + index); } } |
int index = scanFix(pattern, 0, buf, patChars, syms, false); positivePrefix = buf.toString(); | int index = scanFix (pattern, 0, buf, patChars, syms, false); buf.sync(); positivePrefix = buf.getBuffer().toString(); positivePrefixRanges = buf.getRanges(); positivePrefixAttrs = buf.getAttributes(); | private final void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms) { // Initialize to the state the parser expects. negativePrefix = ""; negativeSuffix = ""; positivePrefix = ""; positiveSuffix = ""; decimalSeparatorAlwaysShown = false; groupingSize = 0; minExponentDigits = 0; multiplier = 1; useExponentialNotation = false; groupingUsed = false; maximumFractionDigits = 0; maximumIntegerDigits = 309; minimumFractionDigits = 0; minimumIntegerDigits = 1; StringBuffer buf = new StringBuffer(); String patChars = patternChars(syms); int max = pattern.length(); int index = scanFix(pattern, 0, buf, patChars, syms, false); positivePrefix = buf.toString(); index = scanFormat(pattern, index, patChars, syms, true); index = scanFix(pattern, index, buf, patChars, syms, true); positiveSuffix = buf.toString(); if (index == pattern.length()) { // No negative info. negativePrefix = null; negativeSuffix = null; } else { if (pattern.charAt(index) != syms.getPatternSeparator()) throw new IllegalArgumentException("separator character " + "expected - index: " + index); index = scanFix(pattern, index + 1, buf, patChars, syms, false); negativePrefix = buf.toString(); // We parse the negative format for errors but we don't let // it side-effect this object. index = scanFormat(pattern, index, patChars, syms, false); index = scanFix(pattern, index, buf, patChars, syms, true); negativeSuffix = buf.toString(); if (index != pattern.length()) throw new IllegalArgumentException("end of pattern expected " + "- index: " + index); } } |
index = scanFix(pattern, index, buf, patChars, syms, true); positiveSuffix = buf.toString(); | index = scanFix (pattern, index, buf, patChars, syms, true); buf.sync(); positiveSuffix = buf.getBuffer().toString(); positiveSuffixRanges = buf.getRanges(); positiveSuffixAttrs = buf.getAttributes(); | private final void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms) { // Initialize to the state the parser expects. negativePrefix = ""; negativeSuffix = ""; positivePrefix = ""; positiveSuffix = ""; decimalSeparatorAlwaysShown = false; groupingSize = 0; minExponentDigits = 0; multiplier = 1; useExponentialNotation = false; groupingUsed = false; maximumFractionDigits = 0; maximumIntegerDigits = 309; minimumFractionDigits = 0; minimumIntegerDigits = 1; StringBuffer buf = new StringBuffer(); String patChars = patternChars(syms); int max = pattern.length(); int index = scanFix(pattern, 0, buf, patChars, syms, false); positivePrefix = buf.toString(); index = scanFormat(pattern, index, patChars, syms, true); index = scanFix(pattern, index, buf, patChars, syms, true); positiveSuffix = buf.toString(); if (index == pattern.length()) { // No negative info. negativePrefix = null; negativeSuffix = null; } else { if (pattern.charAt(index) != syms.getPatternSeparator()) throw new IllegalArgumentException("separator character " + "expected - index: " + index); index = scanFix(pattern, index + 1, buf, patChars, syms, false); negativePrefix = buf.toString(); // We parse the negative format for errors but we don't let // it side-effect this object. index = scanFormat(pattern, index, patChars, syms, false); index = scanFix(pattern, index, buf, patChars, syms, true); negativeSuffix = buf.toString(); if (index != pattern.length()) throw new IllegalArgumentException("end of pattern expected " + "- index: " + index); } } |
index = scanFix(pattern, index + 1, buf, patChars, syms, false); negativePrefix = buf.toString(); | index = scanFix (pattern, index + 1, buf, patChars, syms, false); buf.sync(); negativePrefix = buf.getBuffer().toString(); negativePrefixRanges = buf.getRanges(); negativePrefixAttrs = buf.getAttributes(); | private final void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms) { // Initialize to the state the parser expects. negativePrefix = ""; negativeSuffix = ""; positivePrefix = ""; positiveSuffix = ""; decimalSeparatorAlwaysShown = false; groupingSize = 0; minExponentDigits = 0; multiplier = 1; useExponentialNotation = false; groupingUsed = false; maximumFractionDigits = 0; maximumIntegerDigits = 309; minimumFractionDigits = 0; minimumIntegerDigits = 1; StringBuffer buf = new StringBuffer(); String patChars = patternChars(syms); int max = pattern.length(); int index = scanFix(pattern, 0, buf, patChars, syms, false); positivePrefix = buf.toString(); index = scanFormat(pattern, index, patChars, syms, true); index = scanFix(pattern, index, buf, patChars, syms, true); positiveSuffix = buf.toString(); if (index == pattern.length()) { // No negative info. negativePrefix = null; negativeSuffix = null; } else { if (pattern.charAt(index) != syms.getPatternSeparator()) throw new IllegalArgumentException("separator character " + "expected - index: " + index); index = scanFix(pattern, index + 1, buf, patChars, syms, false); negativePrefix = buf.toString(); // We parse the negative format for errors but we don't let // it side-effect this object. index = scanFormat(pattern, index, patChars, syms, false); index = scanFix(pattern, index, buf, patChars, syms, true); negativeSuffix = buf.toString(); if (index != pattern.length()) throw new IllegalArgumentException("end of pattern expected " + "- index: " + index); } } |
index = scanFix(pattern, index, buf, patChars, syms, true); negativeSuffix = buf.toString(); | index = scanFix (pattern, index, buf, patChars, syms, true); buf.sync(); negativeSuffix = buf.getBuffer().toString(); negativeSuffixRanges = buf.getRanges(); negativeSuffixAttrs = buf.getAttributes(); | private final void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms) { // Initialize to the state the parser expects. negativePrefix = ""; negativeSuffix = ""; positivePrefix = ""; positiveSuffix = ""; decimalSeparatorAlwaysShown = false; groupingSize = 0; minExponentDigits = 0; multiplier = 1; useExponentialNotation = false; groupingUsed = false; maximumFractionDigits = 0; maximumIntegerDigits = 309; minimumFractionDigits = 0; minimumIntegerDigits = 1; StringBuffer buf = new StringBuffer(); String patChars = patternChars(syms); int max = pattern.length(); int index = scanFix(pattern, 0, buf, patChars, syms, false); positivePrefix = buf.toString(); index = scanFormat(pattern, index, patChars, syms, true); index = scanFix(pattern, index, buf, patChars, syms, true); positiveSuffix = buf.toString(); if (index == pattern.length()) { // No negative info. negativePrefix = null; negativeSuffix = null; } else { if (pattern.charAt(index) != syms.getPatternSeparator()) throw new IllegalArgumentException("separator character " + "expected - index: " + index); index = scanFix(pattern, index + 1, buf, patChars, syms, false); negativePrefix = buf.toString(); // We parse the negative format for errors but we don't let // it side-effect this object. index = scanFormat(pattern, index, patChars, syms, false); index = scanFix(pattern, index, buf, patChars, syms, true); negativeSuffix = buf.toString(); if (index != pattern.length()) throw new IllegalArgumentException("end of pattern expected " + "- index: " + index); } } |
int total_digits = Math.max(minimumIntegerDigits, groupingUsed ? groupingSize + 1 : 0); | int total_digits = Math.max(minimumIntegerDigits, groupingUsed ? groupingSize + 1: groupingSize); | private final String computePattern(DecimalFormatSymbols syms) { StringBuffer mainPattern = new StringBuffer(); // We have to at least emit a zero for the minimum number of // digits. Past that we need hash marks up to the grouping // separator (and one beyond). int total_digits = Math.max(minimumIntegerDigits, groupingUsed ? groupingSize + 1 : 0); for (int i = 0; i < total_digits - minimumIntegerDigits; ++i) mainPattern.append(syms.getDigit()); for (int i = total_digits - minimumIntegerDigits; i < total_digits; ++i) mainPattern.append(syms.getZeroDigit()); // Inserting the gropuing operator afterwards is easier. if (groupingUsed) mainPattern.insert(mainPattern.length() - groupingSize, syms.getGroupingSeparator()); // See if we need decimal info. if (minimumFractionDigits > 0 || maximumFractionDigits > 0 || decimalSeparatorAlwaysShown) mainPattern.append(syms.getDecimalSeparator()); for (int i = 0; i < minimumFractionDigits; ++i) mainPattern.append(syms.getZeroDigit()); for (int i = minimumFractionDigits; i < maximumFractionDigits; ++i) mainPattern.append(syms.getDigit()); if (useExponentialNotation) { mainPattern.append(syms.getExponential()); for (int i = 0; i < minExponentDigits; ++i) mainPattern.append(syms.getZeroDigit()); if (minExponentDigits == 0) mainPattern.append(syms.getDigit()); } String main = mainPattern.toString(); String patChars = patternChars(syms); mainPattern.setLength(0); quoteFix(mainPattern, positivePrefix, patChars); mainPattern.append(main); quoteFix(mainPattern, positiveSuffix, patChars); if (negativePrefix != null) { quoteFix(mainPattern, negativePrefix, patChars); mainPattern.append(main); quoteFix(mainPattern, negativeSuffix, patChars); } return mainPattern.toString(); } |
public StringBuffer format(double number, StringBuffer dest, FieldPosition fieldPos) { if (Double.isNaN(number)) { dest.append(symbols.getNaN()); if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD) { int index = dest.length(); fieldPos.setBeginIndex(index - symbols.getNaN().length()); fieldPos.setEndIndex(index); } return dest; } boolean is_neg = number < 0; if (is_neg) { if (negativePrefix != null) dest.append(negativePrefix); else { dest.append(symbols.getMinusSign()); dest.append(positivePrefix); } number = -number; } else dest.append(positivePrefix); int integerBeginIndex = dest.length(); int integerEndIndex = 0; if (Double.isInfinite(number)) { dest.append(symbols.getInfinity()); integerEndIndex = dest.length(); } else { number *= multiplier; long exponent = 0; double baseNumber; if (useExponentialNotation) { exponent = (long) Math.floor(Math.log(number) / Math.log(10)); if (minimumIntegerDigits > 0) exponent -= minimumIntegerDigits - 1; baseNumber = (long) (number / Math.pow(10.0, exponent)); } else baseNumber = number; baseNumber += 5 * Math.pow(10.0, -maximumFractionDigits - 1); int index = dest.length(); double intPart = Math.floor(baseNumber); int count = 0; while (count < maximumIntegerDigits && (intPart > 0 || count < minimumIntegerDigits)) { long dig = (long) (intPart % 10); intPart = Math.floor(intPart / 10); if (groupingUsed && count > 0 && count % groupingSize == 0) dest.insert(index, symbols.getGroupingSeparator()); dest.insert(index, (char) (symbols.getZeroDigit() + dig)); ++count; } integerEndIndex = dest.length(); int decimal_index = integerEndIndex; int consecutive_zeros = 0; int total_digits = 0; double fracPart = baseNumber - Math.floor(baseNumber); for (count = 0; count < maximumFractionDigits && (fracPart != 0 || count < minimumFractionDigits); ++count) { ++total_digits; fracPart *= 10; long dig = (long) fracPart; if (dig == 0) ++consecutive_zeros; else consecutive_zeros = 0; dest.append((char) (symbols.getZeroDigit() + dig)); fracPart = fracPart - Math.floor(fracPart); } int extra_zeros = Math.min(consecutive_zeros, total_digits - minimumFractionDigits); if (extra_zeros > 0) { dest.setLength(dest.length() - extra_zeros); total_digits -= extra_zeros; } if (decimalSeparatorAlwaysShown || total_digits > 0) { dest.insert(decimal_index, symbols.getDecimalSeparator()); if (fieldPos != null && fieldPos.getField() == FRACTION_FIELD) { fieldPos.setBeginIndex(decimal_index + 1); fieldPos.setEndIndex(dest.length()); } } if (useExponentialNotation) { dest.append(symbols.getExponential()); if (exponent < 0) { dest.append(symbols.getMinusSign()); exponent = -exponent; } index = dest.length(); for (count = 0; exponent > 0 || count < minExponentDigits; ++count) { long dig = exponent % 10; exponent /= 10; dest.insert(index, (char) (symbols.getZeroDigit() + dig)); } } } if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD) { fieldPos.setBeginIndex(integerBeginIndex); fieldPos.setEndIndex(integerEndIndex); } dest.append((is_neg && negativeSuffix != null) ? negativeSuffix : positiveSuffix); | public StringBuffer format (double number, StringBuffer dest, FieldPosition fieldPos) { formatInternal (number, new StringFormatBuffer(dest), fieldPos); | public StringBuffer format(double number, StringBuffer dest, FieldPosition fieldPos) { // A very special case. if (Double.isNaN(number)) { dest.append(symbols.getNaN()); if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD) { int index = dest.length(); fieldPos.setBeginIndex(index - symbols.getNaN().length()); fieldPos.setEndIndex(index); } return dest; } boolean is_neg = number < 0; if (is_neg) { if (negativePrefix != null) dest.append(negativePrefix); else { dest.append(symbols.getMinusSign()); dest.append(positivePrefix); } number = -number; } else dest.append(positivePrefix); int integerBeginIndex = dest.length(); int integerEndIndex = 0; if (Double.isInfinite(number)) { dest.append(symbols.getInfinity()); integerEndIndex = dest.length(); } else { number *= multiplier; // Compute exponent. long exponent = 0; double baseNumber; if (useExponentialNotation) { exponent = (long) Math.floor(Math.log(number) / Math.log(10)); if (minimumIntegerDigits > 0) exponent -= minimumIntegerDigits - 1; baseNumber = (long) (number / Math.pow(10.0, exponent)); } else baseNumber = number; // Round to the correct number of digits. baseNumber += 5 * Math.pow(10.0, -maximumFractionDigits - 1); int index = dest.length(); double intPart = Math.floor(baseNumber); int count = 0; while (count < maximumIntegerDigits && (intPart > 0 || count < minimumIntegerDigits)) { long dig = (long) (intPart % 10); intPart = Math.floor(intPart / 10); // Append group separator if required. if (groupingUsed && count > 0 && count % groupingSize == 0) dest.insert(index, symbols.getGroupingSeparator()); dest.insert(index, (char) (symbols.getZeroDigit() + dig)); ++count; } integerEndIndex = dest.length(); int decimal_index = integerEndIndex; int consecutive_zeros = 0; int total_digits = 0; // Strip integer part from NUMBER. double fracPart = baseNumber - Math.floor(baseNumber); for (count = 0; count < maximumFractionDigits && (fracPart != 0 || count < minimumFractionDigits); ++count) { ++total_digits; fracPart *= 10; long dig = (long) fracPart; if (dig == 0) ++consecutive_zeros; else consecutive_zeros = 0; dest.append((char) (symbols.getZeroDigit() + dig)); // Strip integer part from FRACPART. fracPart = fracPart - Math.floor(fracPart); } // Strip extraneous trailing `0's. We can't always detect // these in the loop. int extra_zeros = Math.min(consecutive_zeros, total_digits - minimumFractionDigits); if (extra_zeros > 0) { dest.setLength(dest.length() - extra_zeros); total_digits -= extra_zeros; } // If required, add the decimal symbol. if (decimalSeparatorAlwaysShown || total_digits > 0) { dest.insert(decimal_index, symbols.getDecimalSeparator()); if (fieldPos != null && fieldPos.getField() == FRACTION_FIELD) { fieldPos.setBeginIndex(decimal_index + 1); fieldPos.setEndIndex(dest.length()); } } // Finally, print the exponent. if (useExponentialNotation) { dest.append(symbols.getExponential()); if (exponent < 0) { dest.append(symbols.getMinusSign()); exponent = -exponent; } index = dest.length(); for (count = 0; exponent > 0 || count < minExponentDigits; ++count) { long dig = exponent % 10; exponent /= 10; dest.insert(index, (char) (symbols.getZeroDigit() + dig)); } } } if (fieldPos != null && fieldPos.getField() == INTEGER_FIELD) { fieldPos.setBeginIndex(integerBeginIndex); fieldPos.setEndIndex(integerEndIndex); } dest.append((is_neg && negativeSuffix != null) ? negativeSuffix : positiveSuffix); return dest; } |
StringBuffer buf = new StringBuffer(); | StringBuffer int_buf = new StringBuffer (); | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
StringBuffer buf = int_buf; StringBuffer frac_buf = null; StringBuffer exp_buf = null; | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
|
if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { | if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && groupingSize != 0 && (index - last_group) % groupingSize != 0) { | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
last_group = index; } else if (c >= zero && c <= zero + 9) { | last_group = index+1; } else if (c >= zero && c <= zero + 9) { | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
exp_part = false; } else if (parseIntegerOnly) | } else if (parseIntegerOnly) | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { | else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && groupingSize != 0 && (index - last_group) % groupingSize != 0) { | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
buf.append('.'); | buf = frac_buf = new StringBuffer(); frac_buf.append('.'); | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
} else if (c == symbols.getExponential()) { buf.append('E'); | } else if (c == symbols.getExponential()) { buf = exp_buf = new StringBuffer(); | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
} else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { | exp_index = index+1; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
buf.insert(0, '-'); String t = buf.toString(); | int_buf.insert(0, '-'); if (exp_buf != null) { int exponent_value; try { exponent_value = Integer.parseInt(exp_buf.toString()); } catch (NumberFormatException x1) { pos.setErrorIndex(exp_index); return null; } if (frac_buf == null) { for (int i = 0; i < exponent_value; i++) int_buf.append('0'); use_long = true; } else { boolean long_sufficient; if (exponent_value < frac_buf.length()-1) { int lastNonNull = -1; for (int i = 1; i < frac_buf.length(); i++) if (frac_buf.charAt(i) != '0') lastNonNull = i; long_sufficient = (lastNonNull < 0 || lastNonNull <= exponent_value); } else long_sufficient = true; if (long_sufficient) { for (int i = 1; i < frac_buf.length() && i < exponent_value; i++) int_buf.append(frac_buf.charAt(i)); for (int i = frac_buf.length()-1; i < exponent_value; i++) int_buf.append('0'); use_long = true; } else { int_buf.append(frac_buf); int_buf.append('E'); int_buf.append(exp_buf); use_long = false; } } } else { if (frac_buf != null) { int i; for (i = 1; i < frac_buf.length(); i++) if (frac_buf.charAt(i) != '0') break; if (i != frac_buf.length()) { use_long = false; int_buf.append(frac_buf); } else use_long = true; } else use_long = true; } String t = int_buf.toString(); | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { | if (use_long) { try { result = new Long (t); } catch (NumberFormatException x1) { } } else { try { result = new Double (t); | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
} if (result == null) { | catch (NumberFormatException x2) { } } if (result == null) { | public Number parse(String str, ParsePosition pos) { // Our strategy is simple: copy the text into a buffer, // translating or omitting locale-specific information. Then // let Double or Long convert the number for us. boolean is_neg = false; int index = pos.getIndex(); StringBuffer buf = new StringBuffer(); // We have to check both prefixes, because one might be empty. // We want to pick the longest prefix that matches. boolean got_pos = str.startsWith(positivePrefix, index); String np = (negativePrefix != null ? negativePrefix : positivePrefix + symbols.getMinusSign()); boolean got_neg = str.startsWith(np, index); if (got_pos && got_neg) { // By checking this way, we preserve ambiguity in the case // where the negative format differs only in suffix. We // check this again later. if (np.length() > positivePrefix.length()) { is_neg = true; index += np.length(); } else index += positivePrefix.length(); } else if (got_neg) { is_neg = true; index += np.length(); } else if (got_pos) index += positivePrefix.length(); else { pos.setErrorIndex(index); return null; } // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum/maxmimum digit stuff? // What about leading zeros? What about multiplier? int start_index = index; int max = str.length(); char zero = symbols.getZeroDigit(); int last_group = -1; boolean int_part = true; boolean exp_part = false; for (; index < max; ++index) { char c = str.charAt(index); // FIXME: what about grouping size? if (groupingUsed && c == symbols.getGroupingSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } last_group = index; } else if (c >= zero && c <= zero + 9) { buf.append((char) (c - zero + '0')); exp_part = false; } else if (parseIntegerOnly) break; else if (c == symbols.getDecimalSeparator()) { if (last_group != -1 && (index - last_group) % groupingSize != 0) { pos.setErrorIndex(index); return null; } buf.append('.'); int_part = false; } else if (c == symbols.getExponential()) { buf.append('E'); int_part = false; exp_part = true; } else if (exp_part && (c == '+' || c == '-' || c == symbols.getMinusSign())) { // For exponential notation. buf.append(c); } else break; } if (index == start_index) { // Didn't see any digits. pos.setErrorIndex(index); return null; } // Check the suffix. We must do this before converting the // buffer to a number to handle the case of a number which is // the most negative Long. boolean got_pos_suf = str.startsWith(positiveSuffix, index); String ns = (negativePrefix == null ? positiveSuffix : negativeSuffix); boolean got_neg_suf = str.startsWith(ns, index); if (is_neg) { if (!got_neg_suf) { pos.setErrorIndex(index); return null; } } else if (got_pos && got_neg && got_neg_suf) { is_neg = true; } else if (got_pos != got_pos_suf && got_neg != got_neg_suf) { pos.setErrorIndex(index); return null; } String suffix = is_neg ? ns : positiveSuffix; if (is_neg) buf.insert(0, '-'); String t = buf.toString(); Number result = null; try { result = new Long(t); } catch (NumberFormatException x1) { try { result = new Double(t); } catch (NumberFormatException x2) { } } if (result == null) { pos.setErrorIndex(index); return null; } pos.setIndex(index + suffix.length()); return result; } |
private final int scanFix(String pattern, int index, StringBuffer buf, String patChars, DecimalFormatSymbols syms, boolean is_suffix) { | private final int scanFix (String pattern, int index, FormatBuffer buf, String patChars, DecimalFormatSymbols syms, boolean is_suffix) { | private final int scanFix(String pattern, int index, StringBuffer buf, String patChars, DecimalFormatSymbols syms, boolean is_suffix) { int len = pattern.length(); buf.setLength(0); boolean multiplierSet = false; while (index < len) { char c = pattern.charAt(index); if (c == '\'' && index + 1 < len && pattern.charAt(index + 1) == '\'') { buf.append(c); ++index; } else if (c == '\'' && index + 2 < len && pattern.charAt(index + 2) == '\'') { buf.append(pattern.charAt(index + 1)); index += 2; } else if (c == '\u00a4') { if (index + 1 < len && pattern.charAt(index + 1) == '\u00a4') { buf.append(syms.getInternationalCurrencySymbol()); ++index; } else buf.append(syms.getCurrencySymbol()); } else if (is_suffix && c == syms.getPercent()) { if (multiplierSet) throw new IllegalArgumentException("multiplier already set " + "- index: " + index); multiplierSet = true; multiplier = 100; buf.append(c); } else if (is_suffix && c == syms.getPerMill()) { if (multiplierSet) throw new IllegalArgumentException("multiplier already set " + "- index: " + index); multiplierSet = true; multiplier = 1000; buf.append(c); } else if (patChars.indexOf(c) != -1) { // This is a pattern character. break; } else buf.append(c); ++index; } return index; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.