rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException | public static void setLookAndFeel(LookAndFeel newLookAndFeel) throws UnsupportedLookAndFeelException | public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { Class c = Class.forName(className); LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception setLookAndFeel(a); } |
Class c = Class.forName(className); LookAndFeel a = (LookAndFeel) c.newInstance(); setLookAndFeel(a); | if (newLookAndFeel != null && ! newLookAndFeel.isSupportedLookAndFeel()) throw new UnsupportedLookAndFeelException(newLookAndFeel.getName()); LookAndFeel oldLookAndFeel = currentLookAndFeel; if (oldLookAndFeel != null) oldLookAndFeel.uninitialize(); currentLookAndFeel = newLookAndFeel; if (newLookAndFeel != null) { newLookAndFeel.initialize(); currentUIDefaults = newLookAndFeel.getDefaults(); } else { currentUIDefaults = null; } listeners.firePropertyChange("lookAndFeel", oldLookAndFeel, newLookAndFeel); | public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { Class c = Class.forName(className); LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception setLookAndFeel(a); } |
session.addSessionListener(this); | public SessionGUI (Session5250 session) { super(session); this.configurationResource = session.getConfigurationResource(); this.sessionName = session.getSessionName(); sesProps = session.sesProps; sce = new SessionChangeEvent(this); session.getConfiguration().addSessionConfigListener(this); } |
|
variant = variant.toUpperCase().intern(); | variant = variant.intern(); | public Locale(String language, String country, String variant) { // During bootstrap, we already know the strings being passed in are // the correct capitalization, and not null. We can't call // String.toUpperCase during this time, since that depends on the // default locale. if (defaultLocale != null) { language = convertLanguage(language).intern(); country = country.toUpperCase().intern(); variant = variant.toUpperCase().intern(); } this.language = language; this.country = country; this.variant = variant; hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode(); } |
m.minor = Minor.Forwarding; | public OutputStream _invoke(String method, InputStream input, ResponseHandler handler ) throws SystemException { org.omg.CORBA.portable.InputStream in = null; org.omg.CORBA.portable.OutputStream out = null; try { try { out = ref._request(method, true); // Transfer request information. int b; while ((b = input.read()) >= 0) { out.write(b); } in = ref._invoke(out); // Read the returned data. out = handler.createReply(); while ((b = in.read()) >= 0) { out.write(b); } } catch (IOException io_ex) { MARSHAL m = new MARSHAL(); m.initCause(io_ex); throw m; } } catch (ApplicationException ex) { in = ex.getInputStream(); String _id = ex.getId(); throw new MARSHAL(_id, 5101, CompletionStatus.COMPLETED_NO); } catch (RemarshalException remarsh) { _invoke(method, input, handler); } finally { ref._releaseReply(in); } return out; } |
|
public org.omg.CORBA.portable.OutputStream _request(String method, boolean response_expected ) | public Request _request(String method) | public org.omg.CORBA.portable.OutputStream _request(String method, boolean response_expected ) { return delegate.request(this, method, response_expected); } |
return delegate.request(this, method, response_expected); | return delegate.request(this, method); | public org.omg.CORBA.portable.OutputStream _request(String method, boolean response_expected ) { return delegate.request(this, method, response_expected); } |
throws IOException | public void write(int n) { throw new NO_IMPLEMENT(); } |
|
return fcw2 | 0x20; | return (fcw2 & 0x0f) | 0x20; | public int getHighlightedAttr(){ return fcw2 | 0x20; } |
writeOut(outputstream,"<" + indexNodeName + " axisIdRef=\""+axisIdRef+"\"/>"); | writeOut(outputstream,"<" + indexNodeName + " axisIdRef=\""); writeOutAttribute(outputstream, axisIdRef); writeOut(outputstream, "\"/>"); | public void toXMLOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { String nodeNameString = this.classXDFNodeName; // Setup. Sometimes the name of the node we are opening is different from // that specified in the classXDFNodeName (*sigh*) if (newNodeNameString != null) nodeNameString = newNodeNameString; // 0. To be valid XML, we always start an XML block with an // XML declaration (e.g. somehting like "<?xml standalone="no"?>"). // Here we deal with printing out XML Declaration && its attributes/* if ((XMLDeclAttribs !=null) &&(!XMLDeclAttribs.isEmpty())) { indent = ""; writeXMLDeclToOutputStream(outputstream, XMLDeclAttribs); }*/ // 1. open this node, print its simple XML attributes if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired writeOut(outputstream,"<" + nodeNameString + ">"); // print opening statement if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); // bump up the indentation // 2. Print out the axisIdRefs as child nodes Iterator iter = axisIdRefOrder.iterator(); while (iter.hasNext()) { String axisIdRef = (String) iter.next(); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, newindent); // indent node if desired writeOut(outputstream,"<" + indexNodeName + " axisIdRef=\""+axisIdRef+"\"/>"); if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); } // 3. Close this node if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, indent); // indent node if desired writeOut(outputstream,"</" + nodeNameString + ">"); // print opening statement if (Specification.getInstance().isPrettyXDFOutput()) writeOut(outputstream, Constants.NEW_LINE); } |
if (defined newNodeNameString) nodeName = newNodeNameString; | if (newNodeNameString != null) nodeName = newNodeNameString; | public void toXMLOutputStream ( OutputStream outputstream, Hashtable XMLDeclAttribs, String strIndent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) { boolean writeHrefAttribute = false; boolean niceOutput = Specification.getInstance().isPrettyXDFOutput(); String indent = ""; String nodeName = getClassXDFNodeName(); if (defined newNodeNameString) nodeName = newNodeNameString; // indent up one indent = indent + strIndent; //open node if (niceOutput) writeOut(outputstream, indent); writeOut(outputstream, "<" + nodeName ); Href hrefObj = getHref(); //write out just the data XMLDataIOStyle readObj = parentArray.getXMLDataIOStyle(); OutputStream dataOutputStream = outputstream; if (hrefObj !=null) { //write out to another file, String fileName = hrefObj.getSysId(); String hrefName = hrefObj.getName(); if(hrefName == null) { Log.errorln("Error: href object in dataCube lacks name. Data being written into metadata instead.\n"); } else if (fileName != null) { writeHrefAttribute = true; try { dataOutputStream = new FileOutputStream(hrefObj.getSysId()); } catch (IOException e) { //oops, something. is wrong, writ out to the passed in OutputStream Log.warnln("Error: cannot open file:"+fileName+" for writing. Data being written into metadata.\n"); writeHrefAttribute = false; } } else { Log.warnln("Error: href:"+hrefName+" lacks systemId, cannot write data to a separate file."); Log.warnln("Data are being written into metadata instead.\n"); writeHrefAttribute = false; } } else { // no *href* attribute specified, write out to the passed in OutputStream // dataOutputStream = outputstream; // not needed now } // write data node attributes if (writeHrefAttribute) { writeOut(outputstream, " "+HREF_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputstream, hrefObj.getName()); writeOut(outputstream, "\""); } String checksum = getChecksum(); if (checksum != null) { writeOut(outputstream, " "+CHECKSUM_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputstream, checksum.toString()); writeOut(outputstream, "\""); } String encoding = getEncoding(); if (encoding!= null) { writeOut(outputstream, " "+ENCODING_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputstream, encoding.toString()); writeOut(outputstream, "\""); } String compress = getCompression(); if (compress != null) { writeOut(outputstream, " "+COMPRESSION_TYPE_XML_ATTRIBUTE_NAME+"=\""); writeOutAttribute(outputstream, compress.toString()); writeOut(outputstream, "\""); } if (writeHrefAttribute) writeOut(outputstream, "/>"); //we just close the data node now else writeOut(outputstream, ">"); //end of opening code Locator currentLocator = parentArray.createLocator(); AxisInterface fastestAxis = (AxisInterface) parentArray.getAxisList().get(0); //stores the NoDataValues for the parentArray, //used in writing out when NoDataException is caught String[] NoDataValues; if (parentArray.hasFieldAxis()) { NoDataValues = new String[fastestAxis.getLength()]; DataFormat[] dataFormatList = parentArray.getDataFormatList(); for (int i = 0; i < NoDataValues.length; i++) { DataFormat d = dataFormatList[i]; if (d != null && d.getNoDataValue() != null) NoDataValues[i]=d.getNoDataValue().toString(); } } else { NoDataValues = new String[1]; NoDataValues[0] = parentArray.getNoDataValue();/* // what tis this?? If there is no fieldAxis, then no fields, // and hence, only ONE noDataValue. DataFormat d = parentArray.getDataFormat(); for (int i = 0; i < NoDataValues.length; i++) { if (d!=null && d.getNoDataValue() != null) NoDataValues[i] = d.getNoDataValue().toString(); }*/ } if (readObj instanceof TaggedXMLDataIOStyle) { String[] tagOrder = ((TaggedXMLDataIOStyle)readObj).getAxisTags(); int stop = tagOrder.length; String[] tags = new String[stop]; for (int i = stop-1; i >= 0 ; i--) { tags[stop-i-1] = tagOrder[i]; } int[] axes = getMaxDataIndex(); stop =axes.length; int[] axisLength = new int[stop]; for (int i = 0; i < stop; i++) { axisLength[i] =axes[stop - 1 - i]; } writeTaggedData(dataOutputStream, currentLocator, indent, axisLength, tags, 0, fastestAxis, NoDataValues); } //done dealing with with TaggedXMLDataIOSytle else { if (readObj instanceof DelimitedXMLDataIOStyle) { writeDelimitedData( dataOutputStream, currentLocator, (DelimitedXMLDataIOStyle) readObj, fastestAxis, NoDataValues, writeHrefAttribute ? false : true ); } else { writeFormattedData( dataOutputStream, currentLocator, (FormattedXMLDataIOStyle) readObj, fastestAxis, NoDataValues, writeHrefAttribute ? false : true ); } } //close the data section appropriately if (!writeHrefAttribute && niceOutput) { writeOut(outputstream, Constants.NEW_LINE); writeOut(outputstream, indent); } // If we didnt write Href attribute, then means that data // were put into document. We need to close the open data // node appropriately. if (!writeHrefAttribute) writeOut(outputstream, "</" + nodeName + ">"); if (niceOutput) writeOut(outputstream, Constants.NEW_LINE); } |
a.addAttribute(AbstractDocument.ElementNameAttribute, IconElementName); | public static void setIcon(MutableAttributeSet a, Icon c) { a.addAttribute(IconAttribute, c); } |
|
if (SecurityManager.current == null) { try { Class.forName("java.security.Security"); } catch (ClassNotFoundException e) { } } | public static synchronized void setSecurityManager(SecurityManager sm) { // Implementation note: the field lives in SecurityManager because of // bootstrap initialization issues. This method is synchronized so that // no other thread changes it to null before this thread makes the change. if (SecurityManager.current != null) SecurityManager.current.checkPermission (new RuntimePermission("setSecurityManager")); SecurityManager.current = sm; } |
|
SecurityManager sm = securityManager; if (sm != null) sm.checkLink(filename); | public void load(String filename) { if (loadLib(filename) == 0) throw new UnsatisfiedLinkError("Could not load library " + filename); } |
|
if (instance == null) instance = new MetalProgressBarUI(); | if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalProgressBarUI instance; if (o == null) { instance = new MetalProgressBarUI(); instances.put(component, instance); } else instance = (MetalProgressBarUI) o; | public static ComponentUI createUI(JComponent component) { if (instance == null) instance = new MetalProgressBarUI(); return instance; } |
throws IllegalAccessException { | throws IllegalAccessException, JNodeClassNotFoundException { | private void copyStaticField(VmType type, VmField f, Field jf, VmStatics statics, NativeStream os, ObjectEmitter emitter) throws IllegalAccessException { jf.setAccessible(true); final Object val = jf.get(null); final int fType = JvmType.SignatureToType(f.getSignature()); final int idx = ((VmStaticField)f).getStaticsIndex(); if (f.isPrimitive()) { if (f.isWide()) { final long lval; switch (fType) { case JvmType.LONG: lval = ((Long) val).longValue(); break; case JvmType.DOUBLE: lval = Double.doubleToRawLongBits(((Double) val) .doubleValue()); break; default: throw new IllegalArgumentException("Unknown wide type " + fType); } statics.setLong(idx, lval); } else { final int ival; final Class jfType = jf.getType(); if (jfType == boolean.class) { ival = ((Boolean) val).booleanValue() ? 1 : 0; } else if (jfType == byte.class) { ival = ((Byte) val).byteValue(); } else if (jfType == char.class) { ival = ((Character) val).charValue(); } else if (jfType == short.class) { ival = ((Short) val).shortValue(); } else if (jfType == int.class) { ival = ((Number) val).intValue(); } else if (jfType == float.class) { ival = Float.floatToRawIntBits(((Float) val).floatValue()); } else { throw new IllegalArgumentException("Unknown wide type " + fType); } statics.setInt(idx, ival); } } else { if (!Modifier.isAddressType(f.getSignature())) { if (val != null) { emitter.testForValidEmit(val, type.getName()); os.getObjectRef(val); } statics.setObject(idx, val); } } } |
final Class javaType = Class.forName(type.getName()); final FieldInfo fieldInfo = emitter.getFieldInfo(javaType); final Field[] jdkFields = fieldInfo.getJdkStaticFields(); final int max = jdkFields.length; for (int k = 0; k < max; k++) { final Field jdkField = jdkFields[k]; if (jdkField != null) { final VmField f = fieldInfo.getJNodeStaticField(k); if (!f.isTransient()) { try { copyStaticField(type, f, jdkField, statics, os, emitter); } catch (IllegalAccessException ex) { throw new BuildException(ex); } } } | final Class javaType = Class.forName(type.getName()); try { final FieldInfo fieldInfo = emitter.getFieldInfo(javaType); final Field[] jdkFields = fieldInfo.getJdkStaticFields(); final int max = jdkFields.length; for (int k = 0; k < max; k++) { final Field jdkField = jdkFields[k]; if (jdkField != null) { final VmField f = fieldInfo.getJNodeStaticField(k); if (!f.isTransient()) { try { copyStaticField(type, f, jdkField, statics, os, emitter); } catch (IllegalAccessException ex) { throw new BuildException(ex); } } } } } catch (JNodeClassNotFoundException ex) { log("JNode class not found" + ex.getMessage()); | protected void copyStaticFields(VmSystemClassLoader cl, VmStatics statics, NativeStream os, ObjectEmitter emitter) throws ClassNotFoundException { for (Iterator i = cl.getLoadedClasses().iterator(); i.hasNext();) { final VmType type = (VmType) i.next(); final String name = type.getName(); final int cnt = type.getNoDeclaredFields(); if ((cnt > 0) && !name.startsWith("java.")){ final Class javaType = Class.forName(type.getName()); final FieldInfo fieldInfo = emitter.getFieldInfo(javaType); final Field[] jdkFields = fieldInfo.getJdkStaticFields(); final int max = jdkFields.length; for (int k = 0; k < max; k++) { final Field jdkField = jdkFields[k]; if (jdkField != null) { final VmField f = fieldInfo.getJNodeStaticField(k); if (!f.isTransient()) { try { copyStaticField(type, f, jdkField, statics, os, emitter); } catch (IllegalAccessException ex) { throw new BuildException(ex); } } } } } } } |
addCompileHighOptLevel("gnu.classpath"); | protected void setupCompileHighOptLevelPackages() { addCompileHighOptLevel("java.io"); addCompileHighOptLevel("java.lang"); addCompileHighOptLevel("java.lang.ref"); addCompileHighOptLevel("java.lang.reflect"); addCompileHighOptLevel("java.net"); addCompileHighOptLevel("java.security"); addCompileHighOptLevel("java.util"); addCompileHighOptLevel("java.util.jar"); addCompileHighOptLevel("java.util.zip"); addCompileHighOptLevel("javax.naming"); addCompileHighOptLevel("gnu.java.io"); addCompileHighOptLevel("gnu.java.io.decode"); addCompileHighOptLevel("gnu.java.io.encode"); addCompileHighOptLevel("gnu.java.lang"); addCompileHighOptLevel("gnu.java.lang.reflect"); addCompileHighOptLevel("org.jnode.assembler"); addCompileHighOptLevel("org.jnode.boot"); addCompileHighOptLevel("org.jnode.plugin"); addCompileHighOptLevel("org.jnode.plugin.manager"); addCompileHighOptLevel("org.jnode.plugin.model"); addCompileHighOptLevel("org.jnode.protocol.plugin"); addCompileHighOptLevel("org.jnode.protocol.system"); addCompileHighOptLevel("org.jnode.security"); addCompileHighOptLevel("org.jnode.system"); addCompileHighOptLevel("org.jnode.system.event"); addCompileHighOptLevel("org.jnode.system.util"); addCompileHighOptLevel("org.jnode.util"); addCompileHighOptLevel("org.jnode.vm"); addCompileHighOptLevel("org.jnode.vm.bytecode"); addCompileHighOptLevel("org.jnode.vm.classmgr"); addCompileHighOptLevel("org.jnode.vm.compiler"); addCompileHighOptLevel("org.jnode.vm.compiler.ir"); addCompileHighOptLevel("org.jnode.vm.compiler.ir.quad"); addCompileHighOptLevel("org.jnode.vm.memmgr"); addCompileHighOptLevel("org.jnode.vm.memmgr.def"); if (true) { addCompileHighOptLevel("java.awt"); addCompileHighOptLevel("java.awt.event"); addCompileHighOptLevel("java.awt.peer"); addCompileHighOptLevel("java.awt.font"); addCompileHighOptLevel("java.awt.geom"); addPreloadPackage("javax.swing"); addPreloadPackage("javax.swing.border"); addPreloadPackage("javax.swing.event"); addPreloadPackage("javax.swing.plaf"); addPreloadPackage("javax.swing.plaf.basic"); addPreloadPackage("javax.swing.plaf.metal"); } } |
|
Object obj = cp.getAny(i); if (obj instanceof VmConstObject) { | final Object obj = cp.getAny(i); if (obj instanceof VmResolvableConstObject) { | public final void resolveCpRefs(VmClassLoader clc) { if (!resolvedCpRefs) { prepare(); if (superClass != null) { superClass.resolveCpRefs(clc); } /** * Step 2b: Load the classes of my fields */ final int fcnt = getNoDeclaredFields(); for (int i = 0; i < fcnt; i++) { final VmField fs = fieldTable[i]; fs.resolve(clc); } /** * Step 2c: Load the classes of my methods */ final int mcnt = getNoDeclaredMethods(); for (int i = 0; i < mcnt; i++) { final VmMethod mts = methodTable[i]; mts.resolve(clc); } VmCP cp = this.cp; if (cp != null) { for (int i = 0; i < cp.getLength(); i++) { Object obj = cp.getAny(i); if (obj instanceof VmConstObject) { ((VmConstObject) obj).resolve(clc); } } } resolvedCpRefs = true; } } |
public void setAccessible(boolean flag) { | public static void setAccessible(AccessibleObject[] array, boolean flag) { | public void setAccessible(boolean flag) { checkPermission(); secureSetAccessible(flag); } |
secureSetAccessible(flag); } | for (int i = 0; i < array.length; i++) array[i].secureSetAccessible(flag); } | public void setAccessible(boolean flag) { checkPermission(); secureSetAccessible(flag); } |
this.builder = builder; | public BuildObjectResolver(NativeStream os, AbstractBootImageBuilder builder) { this.os = os; this.builder = builder; } |
|
public DefaultHeapManager(VmClassLoader loader, HeapHelper helper, VmStatics statics) throws ClassNotFoundException { super(helper); this.writeBarrier = null; this.firstHeap = new VmDefaultHeap(this); this.currentHeap = firstHeap; this.defaultHeapClass = (VmNormalClass)loader.loadClass(VmDefaultHeap.class.getName(), true); this.statics = statics; } | public DefaultHeapManager(VmClassLoader loader, HeapHelper helper, VmStatics statics) throws ClassNotFoundException { super(helper); this.writeBarrier = null; this.firstNormalHeap = new VmDefaultHeap(this); this.currentHeap = firstNormalHeap; this.heapList = firstNormalHeap; this.defaultHeapClass = (VmNormalClass) loader.loadClass( VmDefaultHeap.class.getName(), true); this.statics = statics; } | public DefaultHeapManager(VmClassLoader loader, HeapHelper helper, VmStatics statics) throws ClassNotFoundException { super(helper); //this.writeBarrier = new DefaultWriteBarrier(helper); this.writeBarrier = null; this.firstHeap = new VmDefaultHeap(this); this.currentHeap = firstHeap; this.defaultHeapClass = (VmNormalClass)loader.loadClass(VmDefaultHeap.class.getName(), true); this.statics = statics; } |
public Vm(VmArchitecture arch, VmHeapManager heapManager, VmStatics statics, boolean debugMode) { | public Vm(String version, VmArchitecture arch, VmHeapManager heapManager, VmStatics statics, boolean debugMode) { | public Vm(VmArchitecture arch, VmHeapManager heapManager, VmStatics statics, boolean debugMode) { instance = this; this.debugMode = debugMode; this.bootstrap = true; this.arch = arch; this.heapManager = heapManager; this.statics = statics; } |
this.version = version; | public Vm(VmArchitecture arch, VmHeapManager heapManager, VmStatics statics, boolean debugMode) { instance = this; this.debugMode = debugMode; this.bootstrap = true; this.arch = arch; this.heapManager = heapManager; this.statics = statics; } |
|
public void get(byte[] dst, int dstOffset, int index, int length) { try { | public int get(int index) { | public void get(byte[] dst, int dstOffset, int index, int length) { try { if (index >= size) { // Index is beyond my data if (next != null) { next.get(dst, dstOffset, index - size, length); } else { throw new IndexOutOfBoundsException("at index " + index); } } else if (index + length <= size) { // All bytes are within my data System.arraycopy(data, start + index, dst, dstOffset, length); } else { // First byte is within my data, last is not if (next != null) { final int myLength = size - index; System.arraycopy(data, start + index, dst, dstOffset, myLength); next.get(dst, dstOffset + myLength, Math.max(0, index - myLength), length - myLength); } else { throw new IndexOutOfBoundsException("at index " + index); } } } catch (IndexOutOfBoundsException ex) { log.debug("get(dst, " + dstOffset + ", " + index + ", " + length + ") start=" + start + ", size=" + size); throw new IndexOutOfBoundsException(ex.getMessage()); } } |
next.get(dst, dstOffset, index - size, length); | return next.get(index - size); | public void get(byte[] dst, int dstOffset, int index, int length) { try { if (index >= size) { // Index is beyond my data if (next != null) { next.get(dst, dstOffset, index - size, length); } else { throw new IndexOutOfBoundsException("at index " + index); } } else if (index + length <= size) { // All bytes are within my data System.arraycopy(data, start + index, dst, dstOffset, length); } else { // First byte is within my data, last is not if (next != null) { final int myLength = size - index; System.arraycopy(data, start + index, dst, dstOffset, myLength); next.get(dst, dstOffset + myLength, Math.max(0, index - myLength), length - myLength); } else { throw new IndexOutOfBoundsException("at index " + index); } } } catch (IndexOutOfBoundsException ex) { log.debug("get(dst, " + dstOffset + ", " + index + ", " + length + ") start=" + start + ", size=" + size); throw new IndexOutOfBoundsException(ex.getMessage()); } } |
} else if (index + length <= size) { System.arraycopy(data, start + index, dst, dstOffset, length); | public void get(byte[] dst, int dstOffset, int index, int length) { try { if (index >= size) { // Index is beyond my data if (next != null) { next.get(dst, dstOffset, index - size, length); } else { throw new IndexOutOfBoundsException("at index " + index); } } else if (index + length <= size) { // All bytes are within my data System.arraycopy(data, start + index, dst, dstOffset, length); } else { // First byte is within my data, last is not if (next != null) { final int myLength = size - index; System.arraycopy(data, start + index, dst, dstOffset, myLength); next.get(dst, dstOffset + myLength, Math.max(0, index - myLength), length - myLength); } else { throw new IndexOutOfBoundsException("at index " + index); } } } catch (IndexOutOfBoundsException ex) { log.debug("get(dst, " + dstOffset + ", " + index + ", " + length + ") start=" + start + ", size=" + size); throw new IndexOutOfBoundsException(ex.getMessage()); } } |
|
if (next != null) { final int myLength = size - index; System.arraycopy(data, start + index, dst, dstOffset, myLength); next.get(dst, dstOffset + myLength, Math.max(0, index - myLength), length - myLength); } else { throw new IndexOutOfBoundsException("at index " + index); } } } catch (IndexOutOfBoundsException ex) { log.debug("get(dst, " + dstOffset + ", " + index + ", " + length + ") start=" + start + ", size=" + size); throw new IndexOutOfBoundsException(ex.getMessage()); | return data[start + index] & 0xFF; | public void get(byte[] dst, int dstOffset, int index, int length) { try { if (index >= size) { // Index is beyond my data if (next != null) { next.get(dst, dstOffset, index - size, length); } else { throw new IndexOutOfBoundsException("at index " + index); } } else if (index + length <= size) { // All bytes are within my data System.arraycopy(data, start + index, dst, dstOffset, length); } else { // First byte is within my data, last is not if (next != null) { final int myLength = size - index; System.arraycopy(data, start + index, dst, dstOffset, myLength); next.get(dst, dstOffset + myLength, Math.max(0, index - myLength), length - myLength); } else { throw new IndexOutOfBoundsException("at index " + index); } } } catch (IndexOutOfBoundsException ex) { log.debug("get(dst, " + dstOffset + ", " + index + ", " + length + ") start=" + start + ", size=" + size); throw new IndexOutOfBoundsException(ex.getMessage()); } } |
double small = getFlatness() * (1E-10); | double small = getFlatness() * EPSILON; | private int getAxisIntersections(double x, double y, boolean useYaxis, double distance) { int nCrossings = 0; double a0; double a1; double a2; double a3; double b0; double b1; double b2; double b3; double[] r = new double[4]; int nRoots; a0 = a3 = 0.0; if (useYaxis) { a0 = getY1() - y; a1 = getCtrlY1() - y; a2 = getCtrlY2() - y; a3 = getY2() - y; b0 = getX1() - x; b1 = getCtrlX1() - x; b2 = getCtrlX2() - x; b3 = getX2() - x; } else { a0 = getX1() - x; a1 = getCtrlX1() - x; a2 = getCtrlX2() - x; a3 = getX2() - x; b0 = getY1() - y; b1 = getCtrlY1() - y; b2 = getCtrlY2() - y; b3 = getY2() - y; } /* If the axis intersects a start/endpoint, shift it up by some small amount to guarantee the line is 'inside' If this is not done, bad behaviour may result for points on that axis.*/ if (a0 == 0.0 || a3 == 0.0) { double small = getFlatness() * (1E-10); if (a0 == 0.0) a0 += small; if (a3 == 0.0) a3 += small; } if (useYaxis) { if (Line2D.linesIntersect(b0, a0, b3, a3, 0.0, 0.0, distance, 0.0)) nCrossings++; } else { if (Line2D.linesIntersect(a0, b0, a3, b3, 0.0, 0.0, 0.0, distance)) nCrossings++; } r[0] = a0; r[1] = 3 * (a1 - a0); r[2] = 3 * (a2 + a0 - 2 * a1); r[3] = a3 - 3 * a2 + 3 * a1 - a0; if ((nRoots = solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { double t = r[i]; if (t >= 0.0 && t <= 1.0) { double crossing = -(t * t * t) * (b0 - 3 * b1 + 3 * b2 - b3) + 3 * t * t * (b0 - 2 * b1 + b2) + 3 * t * (b1 - b0) + b0; if (crossing > 0.0 && crossing <= distance) nCrossings++; } } return (nCrossings); } |
a0 += small; | a0 -= small; | private int getAxisIntersections(double x, double y, boolean useYaxis, double distance) { int nCrossings = 0; double a0; double a1; double a2; double a3; double b0; double b1; double b2; double b3; double[] r = new double[4]; int nRoots; a0 = a3 = 0.0; if (useYaxis) { a0 = getY1() - y; a1 = getCtrlY1() - y; a2 = getCtrlY2() - y; a3 = getY2() - y; b0 = getX1() - x; b1 = getCtrlX1() - x; b2 = getCtrlX2() - x; b3 = getX2() - x; } else { a0 = getX1() - x; a1 = getCtrlX1() - x; a2 = getCtrlX2() - x; a3 = getX2() - x; b0 = getY1() - y; b1 = getCtrlY1() - y; b2 = getCtrlY2() - y; b3 = getY2() - y; } /* If the axis intersects a start/endpoint, shift it up by some small amount to guarantee the line is 'inside' If this is not done, bad behaviour may result for points on that axis.*/ if (a0 == 0.0 || a3 == 0.0) { double small = getFlatness() * (1E-10); if (a0 == 0.0) a0 += small; if (a3 == 0.0) a3 += small; } if (useYaxis) { if (Line2D.linesIntersect(b0, a0, b3, a3, 0.0, 0.0, distance, 0.0)) nCrossings++; } else { if (Line2D.linesIntersect(a0, b0, a3, b3, 0.0, 0.0, 0.0, distance)) nCrossings++; } r[0] = a0; r[1] = 3 * (a1 - a0); r[2] = 3 * (a2 + a0 - 2 * a1); r[3] = a3 - 3 * a2 + 3 * a1 - a0; if ((nRoots = solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { double t = r[i]; if (t >= 0.0 && t <= 1.0) { double crossing = -(t * t * t) * (b0 - 3 * b1 + 3 * b2 - b3) + 3 * t * t * (b0 - 2 * b1 + b2) + 3 * t * (b1 - b0) + b0; if (crossing > 0.0 && crossing <= distance) nCrossings++; } } return (nCrossings); } |
a3 += small; | a3 -= small; | private int getAxisIntersections(double x, double y, boolean useYaxis, double distance) { int nCrossings = 0; double a0; double a1; double a2; double a3; double b0; double b1; double b2; double b3; double[] r = new double[4]; int nRoots; a0 = a3 = 0.0; if (useYaxis) { a0 = getY1() - y; a1 = getCtrlY1() - y; a2 = getCtrlY2() - y; a3 = getY2() - y; b0 = getX1() - x; b1 = getCtrlX1() - x; b2 = getCtrlX2() - x; b3 = getX2() - x; } else { a0 = getX1() - x; a1 = getCtrlX1() - x; a2 = getCtrlX2() - x; a3 = getX2() - x; b0 = getY1() - y; b1 = getCtrlY1() - y; b2 = getCtrlY2() - y; b3 = getY2() - y; } /* If the axis intersects a start/endpoint, shift it up by some small amount to guarantee the line is 'inside' If this is not done, bad behaviour may result for points on that axis.*/ if (a0 == 0.0 || a3 == 0.0) { double small = getFlatness() * (1E-10); if (a0 == 0.0) a0 += small; if (a3 == 0.0) a3 += small; } if (useYaxis) { if (Line2D.linesIntersect(b0, a0, b3, a3, 0.0, 0.0, distance, 0.0)) nCrossings++; } else { if (Line2D.linesIntersect(a0, b0, a3, b3, 0.0, 0.0, 0.0, distance)) nCrossings++; } r[0] = a0; r[1] = 3 * (a1 - a0); r[2] = 3 * (a2 + a0 - 2 * a1); r[3] = a3 - 3 * a2 + 3 * a1 - a0; if ((nRoots = solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { double t = r[i]; if (t >= 0.0 && t <= 1.0) { double crossing = -(t * t * t) * (b0 - 3 * b1 + 3 * b2 - b3) + 3 * t * t * (b0 - 2 * b1 + b2) + 3 * t * (b1 - b0) + b0; if (crossing > 0.0 && crossing <= distance) nCrossings++; } } return (nCrossings); } |
if (Line2D.linesIntersect(b0, a0, b3, a3, 0.0, 0.0, distance, 0.0)) | if (Line2D.linesIntersect(b0, a0, b3, a3, EPSILON, 0.0, distance, 0.0)) | private int getAxisIntersections(double x, double y, boolean useYaxis, double distance) { int nCrossings = 0; double a0; double a1; double a2; double a3; double b0; double b1; double b2; double b3; double[] r = new double[4]; int nRoots; a0 = a3 = 0.0; if (useYaxis) { a0 = getY1() - y; a1 = getCtrlY1() - y; a2 = getCtrlY2() - y; a3 = getY2() - y; b0 = getX1() - x; b1 = getCtrlX1() - x; b2 = getCtrlX2() - x; b3 = getX2() - x; } else { a0 = getX1() - x; a1 = getCtrlX1() - x; a2 = getCtrlX2() - x; a3 = getX2() - x; b0 = getY1() - y; b1 = getCtrlY1() - y; b2 = getCtrlY2() - y; b3 = getY2() - y; } /* If the axis intersects a start/endpoint, shift it up by some small amount to guarantee the line is 'inside' If this is not done, bad behaviour may result for points on that axis.*/ if (a0 == 0.0 || a3 == 0.0) { double small = getFlatness() * (1E-10); if (a0 == 0.0) a0 += small; if (a3 == 0.0) a3 += small; } if (useYaxis) { if (Line2D.linesIntersect(b0, a0, b3, a3, 0.0, 0.0, distance, 0.0)) nCrossings++; } else { if (Line2D.linesIntersect(a0, b0, a3, b3, 0.0, 0.0, 0.0, distance)) nCrossings++; } r[0] = a0; r[1] = 3 * (a1 - a0); r[2] = 3 * (a2 + a0 - 2 * a1); r[3] = a3 - 3 * a2 + 3 * a1 - a0; if ((nRoots = solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { double t = r[i]; if (t >= 0.0 && t <= 1.0) { double crossing = -(t * t * t) * (b0 - 3 * b1 + 3 * b2 - b3) + 3 * t * t * (b0 - 2 * b1 + b2) + 3 * t * (b1 - b0) + b0; if (crossing > 0.0 && crossing <= distance) nCrossings++; } } return (nCrossings); } |
if (Line2D.linesIntersect(a0, b0, a3, b3, 0.0, 0.0, 0.0, distance)) | if (Line2D.linesIntersect(a0, b0, a3, b3, 0.0, EPSILON, 0.0, distance)) | private int getAxisIntersections(double x, double y, boolean useYaxis, double distance) { int nCrossings = 0; double a0; double a1; double a2; double a3; double b0; double b1; double b2; double b3; double[] r = new double[4]; int nRoots; a0 = a3 = 0.0; if (useYaxis) { a0 = getY1() - y; a1 = getCtrlY1() - y; a2 = getCtrlY2() - y; a3 = getY2() - y; b0 = getX1() - x; b1 = getCtrlX1() - x; b2 = getCtrlX2() - x; b3 = getX2() - x; } else { a0 = getX1() - x; a1 = getCtrlX1() - x; a2 = getCtrlX2() - x; a3 = getX2() - x; b0 = getY1() - y; b1 = getCtrlY1() - y; b2 = getCtrlY2() - y; b3 = getY2() - y; } /* If the axis intersects a start/endpoint, shift it up by some small amount to guarantee the line is 'inside' If this is not done, bad behaviour may result for points on that axis.*/ if (a0 == 0.0 || a3 == 0.0) { double small = getFlatness() * (1E-10); if (a0 == 0.0) a0 += small; if (a3 == 0.0) a3 += small; } if (useYaxis) { if (Line2D.linesIntersect(b0, a0, b3, a3, 0.0, 0.0, distance, 0.0)) nCrossings++; } else { if (Line2D.linesIntersect(a0, b0, a3, b3, 0.0, 0.0, 0.0, distance)) nCrossings++; } r[0] = a0; r[1] = 3 * (a1 - a0); r[2] = 3 * (a2 + a0 - 2 * a1); r[3] = a3 - 3 * a2 + 3 * a1 - a0; if ((nRoots = solveCubic(r)) != 0) for (int i = 0; i < nRoots; i++) { double t = r[i]; if (t >= 0.0 && t <= 1.0) { double crossing = -(t * t * t) * (b0 - 3 * b1 + 3 * b2 - b3) + 3 * t * t * (b0 - 2 * b1 + b2) + 3 * t * (b1 - b0) + b0; if (crossing > 0.0 && crossing <= distance) nCrossings++; } } return (nCrossings); } |
throw new IllegalArgumentException(); | throw new IllegalArgumentException("position: " + position + ", beginIndex: " + getBeginIndex() + ", endIndex: " + getEndIndex()); | public char setIndex(int position) { if (position < getBeginIndex() || position > getEndIndex()) throw new IllegalArgumentException(); current = position; if (position == getEndIndex()) return DONE; return array[current]; } |
if (sumDelta == 0) return; | private static void adjustGreater(int allocated, SizeRequirements[] children, int[] spans, int span) { // Sum up (maxSize - prefSize) over all children int sumDelta = 0; for (int i = 0; i < children.length; i++) sumDelta += children[i].maximum - children[i].preferred; // Adjust all sizes according to their preferred and minimum sizes. for (int i = 0; i < children.length; i++) { double factor = ((double) (children[i].maximum - children[i].preferred)) / ((double) sumDelta); spans[i] -= factor * (span - allocated); } } |
|
if (sumDelta == 0) return; | private static void adjustSmaller(int allocated, SizeRequirements[] children, int[] spans, int span) { // Sum up (prefSize - minSize) over all children int sumDelta = 0; for (int i = 0; i < children.length; i++) sumDelta += children[i].preferred - children[i].minimum; // Adjust all sizes according to their preferred and minimum sizes. for (int i = 0; i < children.length; i++) { double factor = ((double) (children[i].preferred - children[i].minimum)) / ((double) sumDelta); // In case we have a sumDelta of 0, the factor should also be 0. if (Double.isNaN(factor)) factor = 0; spans[i] -= factor * (span - allocated); } } |
|
throw new Error("getenv no longer supported, use properties instead: " + name); | if (name == null) throw new NullPointerException(); SecurityManager sm = Runtime.securityManager; if (sm != null) sm.checkPermission(new RuntimePermission("getenv." + name)); return VMSystem.getenv(name); | public static String getenv(String name) { throw new Error("getenv no longer supported, use properties instead: " + name); } |
PublicKey pubK = new GnuRSAPublicKey(n, e); PrivateKey secK = new GnuRSAPrivateKey(p, q, e, d); | PublicKey pubK = new GnuRSAPublicKey(preferredFormat, n, e); PrivateKey secK = new GnuRSAPrivateKey(preferredFormat, p, q, e, d); | public KeyPair generate() { BigInteger p, q, n, d; // 1. Generate a prime p in the interval [2**(M-1), 2**M - 1], where // M = CEILING(L/2), and such that GCD(p, e) = 1 int M = (L + 1) / 2; BigInteger lower = TWO.pow(M - 1); BigInteger upper = TWO.pow(M).subtract(ONE); byte[] kb = new byte[(M + 7) / 8]; // enough bytes to frame M bits step1: while (true) { nextRandomBytes(kb); p = new BigInteger(1, kb).setBit(0); if (p.compareTo(lower) >= 0 && p.compareTo(upper) <= 0 && Prime2.isProbablePrime(p) && p.gcd(e).equals(ONE)) { break step1; } } // 2. Generate a prime q such that the product of p and q is an L-bit // number, and such that GCD(q, e) = 1 step2: while (true) { nextRandomBytes(kb); q = new BigInteger(1, kb).setBit(0); n = p.multiply(q); if (n.bitLength() == L && Prime2.isProbablePrime(q) && q.gcd(e).equals(ONE)) { break step2; } // TODO: test for p != q } // TODO: ensure p < q // 3. Put n = pq. The public key is (n, e). // 4. Compute the parameters necessary for the private key K (see // Section 2.2). BigInteger phi = p.subtract(ONE).multiply(q.subtract(ONE)); d = e.modInverse(phi); // 5. Output the public key and the private key. PublicKey pubK = new GnuRSAPublicKey(n, e); PrivateKey secK = new GnuRSAPrivateKey(p, q, e, d); return new KeyPair(pubK, secK); } |
Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT); preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT : formatID.intValue(); | public void setup(Map attributes) { // do we have a SecureRandom, or should we use our own? rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS); // are we given a set of RSA params or we shall use our own? RSAKeyGenParameterSpec params = (RSAKeyGenParameterSpec) attributes.get(RSA_PARAMETERS); // find out the modulus length if (params != null) { L = params.getKeysize(); e = params.getPublicExponent(); } else { Integer l = (Integer) attributes.get(MODULUS_LENGTH); L = (l == null ? DEFAULT_MODULUS_LENGTH : l.intValue()); } if (L < 1024) { throw new IllegalArgumentException(MODULUS_LENGTH); } } |
|
public BigInteger gcd(BigInteger y) | private static int gcd(int a, int b) | public BigInteger gcd(BigInteger y) { int xval = ival; int yval = y.ival; if (words == null) { if (xval == 0) return abs(y); if (y.words == null && xval != Integer.MIN_VALUE && yval != Integer.MIN_VALUE) { if (xval < 0) xval = -xval; if (yval < 0) yval = -yval; return valueOf(gcd(xval, yval)); } xval = 1; } if (y.words == null) { if (yval == 0) return abs(this); yval = 1; } int len = (xval > yval ? xval : yval) + 1; int[] xwords = new int[len]; int[] ywords = new int[len]; getAbsolute(xwords); y.getAbsolute(ywords); len = MPN.gcd(xwords, ywords, len); BigInteger result = new BigInteger(0); result.ival = len; result.words = xwords; return result.canonicalize(); } |
int xval = ival; int yval = y.ival; if (words == null) | int tmp; if (b > a) | public BigInteger gcd(BigInteger y) { int xval = ival; int yval = y.ival; if (words == null) { if (xval == 0) return abs(y); if (y.words == null && xval != Integer.MIN_VALUE && yval != Integer.MIN_VALUE) { if (xval < 0) xval = -xval; if (yval < 0) yval = -yval; return valueOf(gcd(xval, yval)); } xval = 1; } if (y.words == null) { if (yval == 0) return abs(this); yval = 1; } int len = (xval > yval ? xval : yval) + 1; int[] xwords = new int[len]; int[] ywords = new int[len]; getAbsolute(xwords); y.getAbsolute(ywords); len = MPN.gcd(xwords, ywords, len); BigInteger result = new BigInteger(0); result.ival = len; result.words = xwords; return result.canonicalize(); } |
if (xval == 0) return abs(y); if (y.words == null && xval != Integer.MIN_VALUE && yval != Integer.MIN_VALUE) { if (xval < 0) xval = -xval; if (yval < 0) yval = -yval; return valueOf(gcd(xval, yval)); | tmp = a; a = b; b = tmp; } for(;;) { if (b == 0) return a; if (b == 1) return b; tmp = b; b = a % b; a = tmp; | public BigInteger gcd(BigInteger y) { int xval = ival; int yval = y.ival; if (words == null) { if (xval == 0) return abs(y); if (y.words == null && xval != Integer.MIN_VALUE && yval != Integer.MIN_VALUE) { if (xval < 0) xval = -xval; if (yval < 0) yval = -yval; return valueOf(gcd(xval, yval)); } xval = 1; } if (y.words == null) { if (yval == 0) return abs(this); yval = 1; } int len = (xval > yval ? xval : yval) + 1; int[] xwords = new int[len]; int[] ywords = new int[len]; getAbsolute(xwords); y.getAbsolute(ywords); len = MPN.gcd(xwords, ywords, len); BigInteger result = new BigInteger(0); result.ival = len; result.words = xwords; return result.canonicalize(); } |
xval = 1; | public BigInteger gcd(BigInteger y) { int xval = ival; int yval = y.ival; if (words == null) { if (xval == 0) return abs(y); if (y.words == null && xval != Integer.MIN_VALUE && yval != Integer.MIN_VALUE) { if (xval < 0) xval = -xval; if (yval < 0) yval = -yval; return valueOf(gcd(xval, yval)); } xval = 1; } if (y.words == null) { if (yval == 0) return abs(this); yval = 1; } int len = (xval > yval ? xval : yval) + 1; int[] xwords = new int[len]; int[] ywords = new int[len]; getAbsolute(xwords); y.getAbsolute(ywords); len = MPN.gcd(xwords, ywords, len); BigInteger result = new BigInteger(0); result.ival = len; result.words = xwords; return result.canonicalize(); } |
|
if (y.words == null) { if (yval == 0) return abs(this); yval = 1; } int len = (xval > yval ? xval : yval) + 1; int[] xwords = new int[len]; int[] ywords = new int[len]; getAbsolute(xwords); y.getAbsolute(ywords); len = MPN.gcd(xwords, ywords, len); BigInteger result = new BigInteger(0); result.ival = len; result.words = xwords; return result.canonicalize(); } | public BigInteger gcd(BigInteger y) { int xval = ival; int yval = y.ival; if (words == null) { if (xval == 0) return abs(y); if (y.words == null && xval != Integer.MIN_VALUE && yval != Integer.MIN_VALUE) { if (xval < 0) xval = -xval; if (yval < 0) yval = -yval; return valueOf(gcd(xval, yval)); } xval = 1; } if (y.words == null) { if (yval == 0) return abs(this); yval = 1; } int len = (xval > yval ? xval : yval) + 1; int[] xwords = new int[len]; int[] ywords = new int[len]; getAbsolute(xwords); y.getAbsolute(ywords); len = MPN.gcd(xwords, ywords, len); BigInteger result = new BigInteger(0); result.ival = len; result.words = xwords; return result.canonicalize(); } |
|
public JRootPane createRootPane() | protected JRootPane createRootPane() | public JRootPane createRootPane() { return new JRootPane(); } |
public void setRootPane(JRootPane root) | protected void setRootPane(JRootPane root) | public void setRootPane(JRootPane root) { if (rootPane != null) remove(rootPane); rootPane = root; add(rootPane, BorderLayout.CENTER); } |
Frame(String title) { super(); this.title = title; visible = false; | public Frame() { this(""); | Frame(String title){ super(); this.title = title; // Top-level frames are initially invisible. visible = false; noteFrame(this);} |
Class dclass = Class.forName(dcname); | Class dclass = Class.forName(dcname, true, Thread.currentThread().getContextClassLoader()); | public static synchronized Object getInstance(String type) throws GetDelegateInstanceException { Object r = cache.get(type); if (r != null) return r; String dcname = System.getProperty("javax.rmi.CORBA." + type + "Class"); if (dcname == null) { //throw new DelegateException // ("no javax.rmi.CORBA.XXXClass property sepcified."); dcname = "gnu.javax.rmi.CORBA." + type + "DelegateImpl"; } try { Class dclass = Class.forName(dcname); r = dclass.newInstance(); cache.put(type, r); return r; } catch(Exception e) { throw new GetDelegateInstanceException ("Exception when trying to get delegate instance:" + dcname, e); } } |
attributes = ctx.addAttributes(attributes, s); | addAttributes(s); | public AbstractElement(Element p, AttributeSet s) { element_parent = p; AttributeContext ctx = getAttributeContext(); attributes = ctx.getEmptySet(); if (s != null) attributes = ctx.addAttributes(attributes, s); } |
} if (getAttributeCount() > 0) { for (int i = 0; i < indent; ++i) b.append(' '); | public void dump(PrintStream stream, int indent) { StringBuffer b = new StringBuffer(); for (int i = 0; i < indent; ++i) b.append(' '); b.append('<'); b.append(getName()); // Dump attributes if there are any. if (getAttributeCount() > 0) { b.append('\n'); Enumeration attNames = getAttributeNames(); while (attNames.hasMoreElements()) { for (int i = 0; i < indent + 2; ++i) b.append(' '); Object attName = attNames.nextElement(); b.append(attName); b.append('='); Object attribute = getAttribute(attName); b.append(attribute); b.append('\n'); } } b.append(">\n"); // Dump element content for leaf elements. if (isLeaf()) { for (int i = 0; i < indent + 2; ++i) b.append(' '); int start = getStartOffset(); int end = getEndOffset(); b.append('['); b.append(start); b.append(','); b.append(end); b.append("]["); try { b.append(getDocument().getText(start, end - start)); } catch (BadLocationException ex) { AssertionError err = new AssertionError("BadLocationException " + "must not be thrown " + "here."); err.initCause(ex); throw err; } b.append("]\n"); } stream.print(b.toString()); // Dump child elements if any. int count = getElementCount(); for (int i = 0; i < count; ++i) { Element el = getElement(i); if (el instanceof AbstractElement) ((AbstractElement) el).dump(stream, indent + 2); } } |
|
return (String) getAttribute(NameAttribute); | return (String) attributes.getAttribute(ElementNameAttribute); | public String getName() { return (String) getAttribute(NameAttribute); } |
startOffset = -1; endOffset = -1; | children = new Element[1]; numChildren = 0; lastIndex = -1; | public BranchElement(Element parent, AttributeSet attributes) { super(parent, attributes); startOffset = -1; endOffset = -1; } |
if (children.length == 0) | if (numChildren == 0) | public Enumeration children() { if (children.length == 0) return null; Vector tmp = new Vector(); for (int index = 0; index < children.length; ++index) tmp.add(children[index]); return tmp.elements(); } |
for (int index = 0; index < children.length; ++index) | for (int index = 0; index < numChildren; ++index) | public Enumeration children() { if (children.length == 0) return null; Vector tmp = new Vector(); for (int index = 0; index < children.length; ++index) tmp.add(children[index]); return tmp.elements(); } |
if (index < 0 || index >= children.length) | if (index < 0 || index >= numChildren) | public Element getElement(int index) { if (index < 0 || index >= children.length) return null; return children[index]; } |
return children.length; | return numChildren; | public int getElementCount() { return children.length; } |
if (offset < getStartOffset()) return 0; for (int index = 0; index < children.length - 1; ++index) | int i0 = 0; int i1 = numChildren - 1; int index = -1; int p0 = getStartOffset(); int p1; if (numChildren == 0) index = 0; else if (offset >= getEndOffset()) index = numChildren - 1; else | public int getElementIndex(int offset) { // If offset is less than the start offset of our first child, // return 0 if (offset < getStartOffset()) return 0; // XXX: There is surely a better algorithm // as beginning from first element each time. for (int index = 0; index < children.length - 1; ++index) { Element elem = children[index]; if ((elem.getStartOffset() <= offset) && (offset < elem.getEndOffset())) return index; // If the next element's start offset is greater than offset // then we have to return the closest Element, since no Elements // will contain the offset if (children[index + 1].getStartOffset() > offset) { if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset)) return index + 1; else return index; } } // If offset is greater than the index of the last element, return // the index of the last element. return getElementCount() - 1; } |
Element elem = children[index]; | if (lastIndex >= i0 && lastIndex <= i1) { Element last = getElement(lastIndex); p0 = last.getStartOffset(); p1 = last.getEndOffset(); if (offset >= p0 && offset < p1) index = lastIndex; else { if (offset < p0) i1 = lastIndex; else i0 = lastIndex; } } int i = 0; while (i0 <= i1 && index == -1) { i = i0 + (i1 - i0) / 2; Element el = getElement(i); p0 = el.getStartOffset(); p1 = el.getEndOffset(); if (offset >= p0 && offset < p1) { index = i; } else if (offset < p0) i1 = i - 1; else i0 = i + 1; } | public int getElementIndex(int offset) { // If offset is less than the start offset of our first child, // return 0 if (offset < getStartOffset()) return 0; // XXX: There is surely a better algorithm // as beginning from first element each time. for (int index = 0; index < children.length - 1; ++index) { Element elem = children[index]; if ((elem.getStartOffset() <= offset) && (offset < elem.getEndOffset())) return index; // If the next element's start offset is greater than offset // then we have to return the closest Element, since no Elements // will contain the offset if (children[index + 1].getStartOffset() > offset) { if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset)) return index + 1; else return index; } } // If offset is greater than the index of the last element, return // the index of the last element. return getElementCount() - 1; } |
if ((elem.getStartOffset() <= offset) && (offset < elem.getEndOffset())) return index; if (children[index + 1].getStartOffset() > offset) | if (index == -1) | public int getElementIndex(int offset) { // If offset is less than the start offset of our first child, // return 0 if (offset < getStartOffset()) return 0; // XXX: There is surely a better algorithm // as beginning from first element each time. for (int index = 0; index < children.length - 1; ++index) { Element elem = children[index]; if ((elem.getStartOffset() <= offset) && (offset < elem.getEndOffset())) return index; // If the next element's start offset is greater than offset // then we have to return the closest Element, since no Elements // will contain the offset if (children[index + 1].getStartOffset() > offset) { if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset)) return index + 1; else return index; } } // If offset is greater than the index of the last element, return // the index of the last element. return getElementCount() - 1; } |
if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset)) return index + 1; | if (offset < p0) index = i; | public int getElementIndex(int offset) { // If offset is less than the start offset of our first child, // return 0 if (offset < getStartOffset()) return 0; // XXX: There is surely a better algorithm // as beginning from first element each time. for (int index = 0; index < children.length - 1; ++index) { Element elem = children[index]; if ((elem.getStartOffset() <= offset) && (offset < elem.getEndOffset())) return index; // If the next element's start offset is greater than offset // then we have to return the closest Element, since no Elements // will contain the offset if (children[index + 1].getStartOffset() > offset) { if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset)) return index + 1; else return index; } } // If offset is greater than the index of the last element, return // the index of the last element. return getElementCount() - 1; } |
return index; } | index = i + 1; | public int getElementIndex(int offset) { // If offset is less than the start offset of our first child, // return 0 if (offset < getStartOffset()) return 0; // XXX: There is surely a better algorithm // as beginning from first element each time. for (int index = 0; index < children.length - 1; ++index) { Element elem = children[index]; if ((elem.getStartOffset() <= offset) && (offset < elem.getEndOffset())) return index; // If the next element's start offset is greater than offset // then we have to return the closest Element, since no Elements // will contain the offset if (children[index + 1].getStartOffset() > offset) { if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset)) return index + 1; else return index; } } // If offset is greater than the index of the last element, return // the index of the last element. return getElementCount() - 1; } |
return getElementCount() - 1; | lastIndex = index; } return index; | public int getElementIndex(int offset) { // If offset is less than the start offset of our first child, // return 0 if (offset < getStartOffset()) return 0; // XXX: There is surely a better algorithm // as beginning from first element each time. for (int index = 0; index < children.length - 1; ++index) { Element elem = children[index]; if ((elem.getStartOffset() <= offset) && (offset < elem.getEndOffset())) return index; // If the next element's start offset is greater than offset // then we have to return the closest Element, since no Elements // will contain the offset if (children[index + 1].getStartOffset() > offset) { if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset)) return index + 1; else return index; } } // If offset is greater than the index of the last element, return // the index of the last element. return getElementCount() - 1; } |
if (children.length == 0) { if (endOffset == -1) throw new NullPointerException("BranchElement has no children."); } else endOffset = children[children.length - 1].getEndOffset(); return endOffset; | Element child = numChildren > 0 ? children[numChildren - 1] : children[0]; return child.getEndOffset(); | public int getEndOffset() { if (children.length == 0) { if (endOffset == -1) throw new NullPointerException("BranchElement has no children."); } else endOffset = children[children.length - 1].getEndOffset(); return endOffset; } |
if (children.length == 0) { if (startOffset == -1) throw new NullPointerException("BranchElement has no children."); } else startOffset = children[0].getStartOffset(); return startOffset; | return children[0].getStartOffset(); | public int getStartOffset() { if (children.length == 0) { if (startOffset == -1) throw new NullPointerException("BranchElement has no children."); } else startOffset = children[0].getStartOffset(); return startOffset; } |
for (int index = 0; index < children.length; ++index) | for (int index = 0; index < numChildren; ++index) | public Element positionToElement(int position) { // XXX: There is surely a better algorithm // as beginning from first element each time. for (int index = 0; index < children.length; ++index) { Element elem = children[index]; if ((elem.getStartOffset() <= position) && (position < elem.getEndOffset())) return elem; } return null; } |
Element[] target = new Element[children.length - length + elements.length]; | int delta = elements.length - length; int copyFrom = offset + length; int copyTo = copyFrom + delta; int numMove = numChildren - copyFrom; if (numChildren + delta > children.length) { int newSize = Math.max(2 * children.length, numChildren + delta); Element[] target = new Element[newSize]; | public void replace(int offset, int length, Element[] elements) { Element[] target = new Element[children.length - length + elements.length]; System.arraycopy(children, 0, target, 0, offset); System.arraycopy(elements, 0, target, offset, elements.length); System.arraycopy(children, offset + length, target, offset + elements.length, children.length - offset - length); children = target; } |
System.arraycopy(children, offset + length, target, offset + elements.length, children.length - offset - length); | System.arraycopy(children, copyFrom, target, copyTo, numMove); | public void replace(int offset, int length, Element[] elements) { Element[] target = new Element[children.length - length + elements.length]; System.arraycopy(children, 0, target, 0, offset); System.arraycopy(elements, 0, target, offset, elements.length); System.arraycopy(children, offset + length, target, offset + elements.length, children.length - offset - length); children = target; } |
else { System.arraycopy(children, copyFrom, children, copyTo, numMove); System.arraycopy(elements, 0, children, offset, elements.length); } numChildren += delta; } | public void replace(int offset, int length, Element[] elements) { Element[] target = new Element[children.length - length + elements.length]; System.arraycopy(children, 0, target, 0, offset); System.arraycopy(elements, 0, target, offset, elements.length); System.arraycopy(children, offset + length, target, offset + elements.length, children.length - offset - length); children = target; } |
|
int len = content.length(); startDelta = 0; if (start > len) startDelta = start - len; endDelta = 0; if (end > len) endDelta = end - len; | public LeafElement(Element parent, AttributeSet attributes, int start, int end) { super(parent, attributes); int len = content.length(); startDelta = 0; if (start > len) startDelta = start - len; endDelta = 0; if (end > len) endDelta = end - len; try { startPos = createPosition(start - startDelta); endPos = createPosition(end - endDelta); } catch (BadLocationException ex) { AssertionError as; as = new AssertionError("BadLocationException thrown " + "here. start=" + start + ", end=" + end + ", length=" + getLength()); as.initCause(ex); throw as; } } |
|
startPos = createPosition(start - startDelta); endPos = createPosition(end - endDelta); | startPos = createPosition(start); endPos = createPosition(end); | public LeafElement(Element parent, AttributeSet attributes, int start, int end) { super(parent, attributes); int len = content.length(); startDelta = 0; if (start > len) startDelta = start - len; endDelta = 0; if (end > len) endDelta = end - len; try { startPos = createPosition(start - startDelta); endPos = createPosition(end - endDelta); } catch (BadLocationException ex) { AssertionError as; as = new AssertionError("BadLocationException thrown " + "here. start=" + start + ", end=" + end + ", length=" + getLength()); as.initCause(ex); throw as; } } |
return endPos.getOffset() + endDelta; | return endPos.getOffset(); | public int getEndOffset() { return endPos.getOffset() + endDelta; } |
return startPos.getOffset() + startDelta; | return startPos.getOffset(); | public int getStartOffset() { return startPos.getOffset() + startDelta; } |
((AbstractElement) getBidiRootElement()).dump(out, 0); | public void dump(PrintStream out) { ((AbstractElement) getDefaultRootElement()).dump(out, 0); } |
|
return 0; | Object val = getProperty(AsyncLoadPriority); int prio = -1; if (val != null) prio = ((Integer) val).intValue(); return prio; | public int getAsynchronousLoadPriority() { return 0; } |
return null; | return bidiRoot; | public Element getBidiRootElement() { return null; } |
return new Position() | Position p; try | public final Position getEndPosition() { // FIXME: Properly implement this by calling Content.createPosition(). return new Position() { public int getOffset() { return getLength(); } }; } |
public int getOffset() | p = createPosition(content.length()); } catch (BadLocationException ex) | public final Position getEndPosition() { // FIXME: Properly implement this by calling Content.createPosition(). return new Position() { public int getOffset() { return getLength(); } }; } |
return getLength(); | p = null; | public final Position getEndPosition() { // FIXME: Properly implement this by calling Content.createPosition(). return new Position() { public int getOffset() { return getLength(); } }; } |
}; | return p; | public final Position getEndPosition() { // FIXME: Properly implement this by calling Content.createPosition(). return new Position() { public int getOffset() { return getLength(); } }; } |
Element[] elements = new Element[1]; | Element[] elements = new Element[2]; | public Element[] getRootElements() { Element[] elements = new Element[1]; elements[0] = getDefaultRootElement(); return elements; } |
elements[1] = getBidiRootElement(); | public Element[] getRootElements() { Element[] elements = new Element[1]; elements[0] = getDefaultRootElement(); return elements; } |
|
return new Position() | Position p; try | public final Position getStartPosition() { // FIXME: Properly implement this using Content.createPosition(). return new Position() { public int getOffset() { return 0; } }; } |
public int getOffset() | p = createPosition(0); } catch (BadLocationException ex) | public final Position getStartPosition() { // FIXME: Properly implement this using Content.createPosition(). return new Position() { public int getOffset() { return 0; } }; } |
return 0; | p = null; | public final Position getStartPosition() { // FIXME: Properly implement this using Content.createPosition(). return new Position() { public int getOffset() { return 0; } }; } |
}; | return p; | public final Position getStartPosition() { // FIXME: Properly implement this using Content.createPosition(). return new Position() { public int getOffset() { return 0; } }; } |
finally { writeUnlock(); } } | public void insertString(int offset, String text, AttributeSet attributes) throws BadLocationException { // Bail out if we have a bogus insertion (Behavior observed in RI). if (text == null || text.length() == 0) return; if (documentFilter == null) insertStringImpl(offset, text, attributes); else documentFilter.insertString(getBypass(), offset, text, attributes); } |
|
try { writeLock(); | void insertStringImpl(int offset, String text, AttributeSet attributes) throws BadLocationException { // Just return when no text to insert was given. if (text == null || text.length() == 0) return; DefaultDocumentEvent event = new DefaultDocumentEvent(offset, text.length(), DocumentEvent.EventType.INSERT); try { writeLock(); UndoableEdit undo = content.insertString(offset, text); if (undo != null) event.addEdit(undo); insertUpdate(event, attributes); fireInsertUpdate(event); if (undo != null) fireUndoableEditUpdate(new UndoableEditEvent(this, undo)); } finally { writeUnlock(); } } |
|
finally { writeUnlock(); } } | void insertStringImpl(int offset, String text, AttributeSet attributes) throws BadLocationException { // Just return when no text to insert was given. if (text == null || text.length() == 0) return; DefaultDocumentEvent event = new DefaultDocumentEvent(offset, text.length(), DocumentEvent.EventType.INSERT); try { writeLock(); UndoableEdit undo = content.insertString(offset, text); if (undo != null) event.addEdit(undo); insertUpdate(event, attributes); fireInsertUpdate(event); if (undo != null) fireUndoableEditUpdate(new UndoableEditEvent(this, undo)); } finally { writeUnlock(); } } |
|
if (Boolean.TRUE.equals(getProperty(I18N))) updateBidi(chng); | protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr) { // Do nothing here. Subclasses may want to override this. } |
|
if (Boolean.TRUE.equals(getProperty(I18N))) updateBidi(chng); | protected void postRemoveUpdate(DefaultDocumentEvent chng) { // Do nothing here. Subclasses may want to override this. } |
|
if (TextAttribute.RUN_DIRECTION.equals(key)) { if (TextAttribute.RUN_DIRECTION_RTL.equals(value) && Boolean.FALSE.equals(getProperty(I18N))) putProperty(I18N, Boolean.TRUE); if (Boolean.TRUE.equals(getProperty(I18N))) { writeLock(); try { DefaultDocumentEvent ev = new DefaultDocumentEvent(0, getLength(), DocumentEvent.EventType.INSERT); updateBidi(ev); } finally { writeUnlock(); } } } | public final void putProperty(Object key, Object value) { // FIXME: make me thread-safe if (properties == null) properties = new Hashtable(); properties.put(key, value); } |
|
if (length <= 0) return; | if (length > 0) { if (offset < 0 || offset > getLength()) throw new BadLocationException("Invalid remove position", offset); if (offset + length > getLength()) throw new BadLocationException("Invalid remove length", offset); | void removeImpl(int offset, int length) throws BadLocationException { // Prevent some unneccessary method invocation (observed in the RI). if (length <= 0) return; DefaultDocumentEvent event = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.REMOVE); try { writeLock(); // The order of the operations below is critical! removeUpdate(event); UndoableEdit temp = content.remove(offset, length); postRemoveUpdate(event); fireRemoveUpdate(event); } finally { writeUnlock(); } } |
} | void removeImpl(int offset, int length) throws BadLocationException { // Prevent some unneccessary method invocation (observed in the RI). if (length <= 0) return; DefaultDocumentEvent event = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.REMOVE); try { writeLock(); // The order of the operations below is critical! removeUpdate(event); UndoableEdit temp = content.remove(offset, length); postRemoveUpdate(event); fireRemoveUpdate(event); } finally { writeUnlock(); } } |
|
} finally { writeUnlock(); } | public void replace(int offset, int length, String text, AttributeSet attributes) throws BadLocationException { // Bail out if we have a bogus replacement (Behavior observed in RI). if (length == 0 && (text == null || text.length() == 0)) return; if (documentFilter == null) { // It is important to call the methods which again do the checks // of the arguments and the DocumentFilter because subclasses may // have overridden these methods and provide crucial behavior // which would be skipped if we call the non-checking variants. // An example for this is PlainDocument where insertString can // provide a filtering of newlines. remove(offset, length); insertString(offset, text, attributes); } else documentFilter.replace(getBypass(), offset, length, text, attributes); } |
|
Integer val = p >= 0 ? new Integer(p) : null; putProperty(AsyncLoadPriority, val); | public void setAsynchronousLoadPriority(int p) { // TODO: Implement this properly. } |
|
public PrincipalHolder(Principal initial_value) | public PrincipalHolder() | public PrincipalHolder(Principal initial_value) { value = initial_value; } |
value = initial_value; | public PrincipalHolder(Principal initial_value) { value = initial_value; } |
|
assert(mark <= gapStart || mark > gapEnd); | public int getOffset() { if (mark <= gapStart) return mark; else return mark - (gapEnd - gapStart); } |
|
if (newGapStart == gapStart) return; else if (newGapStart < gapStart) | if (newGapStart < gapStart) | protected void shiftGap(int newGapStart) { int newGapEnd = newGapStart + (gapEnd - gapStart); // Update the positions between newGapEnd and (old) gapEnd. The marks // must be shifted by (gapEnd - newGapEnd). int index1 = Collections.binarySearch(positions, new GapContentPosition(gapEnd)); int index2 = Collections.binarySearch(positions, new GapContentPosition(newGapEnd)); if (index1 > 0 && index2 > 0) { int i1 = Math.min(index1, index2); int i2 = Math.max(index1, index2); for (ListIterator i = positions.listIterator(i1); i.hasNext();) { if (i.nextIndex() > i2) break; GapContentPosition p = (GapContentPosition) i.next(); p.mark += gapEnd - newGapEnd; } } if (newGapStart == gapStart) return; else if (newGapStart < gapStart) { System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart - newGapStart); gapStart = newGapStart; gapEnd = newGapEnd; } else { System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart - gapStart); gapStart = newGapStart; gapEnd = newGapEnd; } } |