bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
protected final void verifyInvoke(VmConstMethodRef methodRef) { if (currentKernelSpace) { // May only call methods with kernelspace pragma. methodRef.resolve(currentMethod.getDeclaringClass().getLoader()); final VmMethod callee = methodRef.getResolvedVmMethod(); if (!callee.hasKernelSpacePragma()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls method outside KernelSpace: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls method outside KernelSpace: " + callee.getFullName()); } if (callee.isSynchronized()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls synchronized method: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls synchronized method: " + callee.getFullName()); } } }
protected final void verifyInvoke(VmConstMethodRef methodRef) { if (currentKernelSpace || currentUninterruptible) { // May only call methods with kernelspace pragma. methodRef.resolve(currentMethod.getDeclaringClass().getLoader()); final VmMethod callee = methodRef.getResolvedVmMethod(); if (!callee.hasKernelSpacePragma()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls method outside KernelSpace: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls method outside KernelSpace: " + callee.getFullName()); } if (callee.isSynchronized()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls synchronized method: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls synchronized method: " + callee.getFullName()); } } }
6,413
protected final void verifyInvoke(VmConstMethodRef methodRef) { if (currentKernelSpace) { // May only call methods with kernelspace pragma. methodRef.resolve(currentMethod.getDeclaringClass().getLoader()); final VmMethod callee = methodRef.getResolvedVmMethod(); if (!callee.hasKernelSpacePragma()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls method outside KernelSpace: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls method outside KernelSpace: " + callee.getFullName()); } if (callee.isSynchronized()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls synchronized method: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls synchronized method: " + callee.getFullName()); } } }
protected final void verifyInvoke(VmConstMethodRef methodRef) { if (currentKernelSpace) { // May only call methods with kernelspace pragma. methodRef.resolve(currentMethod.getDeclaringClass().getLoader()); final VmMethod callee = methodRef.getResolvedVmMethod(); if (!callee.hasKernelSpacePragma()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls method outside KernelSpace: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls method outside KernelSpace: " + callee.getFullName()); } if (callee.isSynchronized()) { //throw new ClassFormatError("Method '" + currentMethod + "' calls synchronized method: " + callee); System.out.println("Method '" + currentMethod.getFullName() + "' calls synchronized method: " + callee.getFullName()); } } }
6,414
public void removeElementAt(int index) { int selected = getIndexOf(selectedItem); if (selected == index) // choose a new selected item { if (selected > 0) selectedItem = getElementAt(selected - 1); else selectedItem = getElementAt(selected + 1); } list.removeElementAt(index); fireIntervalRemoved(this, index, index); }
public void removeElementAt(int index) { int selected = getIndexOf(selectedItem); if (selected == index) // choose a new selected item { if (selected > 0) setSelectedItem(getElementAt(selected - 1)); else selectedItem = getElementAt(selected + 1); } list.removeElementAt(index); fireIntervalRemoved(this, index, index); }
6,415
public void removeElementAt(int index) { int selected = getIndexOf(selectedItem); if (selected == index) // choose a new selected item { if (selected > 0) selectedItem = getElementAt(selected - 1); else selectedItem = getElementAt(selected + 1); } list.removeElementAt(index); fireIntervalRemoved(this, index, index); }
public void removeElementAt(int index) { int selected = getIndexOf(selectedItem); if (selected == index) // choose a new selected item { if (selected > 0) selectedItem = getElementAt(selected - 1); else setSelectedItem(getElementAt(selected + 1)); } list.removeElementAt(index); fireIntervalRemoved(this, index, index); }
6,416
static final DoubleWordItem requestDoubleWordRegisters( EmitterContext eContext, int jvmType) { final X86RegisterPool pool = eContext.getPool(); final Register lsb = requestRegister(eContext, JvmType.INT, false); final Register msb = requestRegister(eContext, JvmType.INT, false); final DoubleWordItem result = DoubleWordItem.createReg(jvmType, lsb, msb); pool.transferOwnerTo(lsb, result); pool.transferOwnerTo(msb, result); return result; }
static final DoubleWordItem requestDoubleWordRegisters( EmitterContext eContext, int jvmType) { final X86RegisterPool pool = eContext.getPool(); final Register lsb = requestRegister(eContext, JvmType.INT, false); final Register msb = requestRegister(eContext, JvmType.INT, false); final DoubleWordItem result = ifac.createReg(jvmType, lsb, msb); pool.transferOwnerTo(lsb, result); pool.transferOwnerTo(msb, result); return result; }
6,417
static final WordItem requestWordRegister(EmitterContext eContext, int jvmType, boolean supportsBits8) { final X86RegisterPool pool = eContext.getPool(); final Register reg = requestRegister(eContext, JvmType.INT, supportsBits8); final WordItem result = WordItem.createReg(jvmType, reg); pool.transferOwnerTo(reg, result); return result; }
static final WordItem requestWordRegister(EmitterContext eContext, int jvmType, boolean supportsBits8) { final X86RegisterPool pool = eContext.getPool(); final Register reg = requestRegister(eContext, JvmType.INT, supportsBits8); final WordItem result = ifac.createReg(jvmType, reg); pool.transferOwnerTo(reg, result); return result; }
6,418
ChangeListener createScrollListener() { return new ChangeListener() { public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } } }; }
ChangeListener createScrollListener() { return new ChangeListener() { public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValues(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } } }; }
6,419
ChangeListener createScrollListener() { return new ChangeListener() { public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } } }; }
ChangeListener createScrollListener() { return new ChangeListener() { public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValues(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } } }; }
6,420
public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } }
public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValues(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } }
6,421
public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValue(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } }
public void stateChanged(ChangeEvent event) { JScrollBar vsb = JScrollPane.this.getVerticalScrollBar(); JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar(); JViewport vp = JScrollPane.this.getViewport(); if (vp != null && event.getSource() == vp) { // if the viewport changed, we should update the VSB / HSB // models according to the new vertical and horizontal sizes Rectangle vr = vp.getViewRect(); Dimension vs = vp.getViewSize(); if (vsb != null && (vsb.getMinimum() != 0 || vsb.getMaximum() != vs.height || vsb.getValue() != vr.y || vsb.getVisibleAmount() != vr.height)) vsb.setValue(vr.y, vr.height, 0, vs.height); if (hsb != null && (hsb.getMinimum() != 0 || hsb.getMaximum() != vs.width || hsb.getValue() != vr.width || hsb.getVisibleAmount() != vr.height)) hsb.setValues(vr.x, vr.width, 0, vs.width); } else { // otherwise we got a change update from either the VSB or // HSB model, and we need to update the viewport positions of // both the main viewport and any row or column headers to // match. int xpos = 0; int ypos = 0; if (vsb != null) ypos = vsb.getValue(); if (hsb != null) xpos = hsb.getValue(); Point pt = new Point(xpos, ypos); if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); pt.x = 0; if (rowHeader != null && rowHeader.getViewPosition() != pt) rowHeader.setViewPosition(pt); pt.x = xpos; pt.y = 0; if (columnHeader != null && columnHeader.getViewPosition() != pt) columnHeader.setViewPosition(pt); } }
6,422
public SwingListPeer(final List list) { super(); SwingToolkit.add(list, this); SwingToolkit.copyAwtProperties(list, this); final ListModel model = new AbstractListModel() { public int getSize() { return list.getItemCount(); } public Object getElementAt(int idx) { return list.getItem(idx); } }; }
public SwingListPeer(final List list) { this.list = list; SwingToolkit.add(list, this); SwingToolkit.copyAwtProperties(list, this); final ListModel model = new AbstractListModel() { public int getSize() { return list.getItemCount(); } public Object getElementAt(int idx) { return list.getItem(idx); } }; }
6,423
public SwingListPeer(final List list) { super(); SwingToolkit.add(list, this); SwingToolkit.copyAwtProperties(list, this); final ListModel model = new AbstractListModel() { public int getSize() { return list.getItemCount(); } public Object getElementAt(int idx) { return list.getItem(idx); } }; }
public SwingListPeer(final List list) { super(); SwingToolkit.add(list, this); SwingToolkit.copyAwtProperties(list, this); final ListModel model = new AbstractListModel() { public int getSize() { return list.getItemCount(); } public Object getElementAt(int idx) { return list.getItem(idx); } }; }
6,424
public void addNodeChangeListener(NodeChangeListener listener) { // XXX }
public void addNodeChangeListener(NodeChangeListener listener) { synchronized (lock) { if (isRemoved()) throw new IllegalStateException("node has been removed"); if (listener == null) throw new NullPointerException("listener is null"); if (nodeListeners == null) nodeListeners = new ArrayList(); nodeListeners.add(listener); } // XXX }
6,425
public void addPreferenceChangeListener(PreferenceChangeListener listener) { // XXX }
public void addPreferenceChangeListener(PreferenceChangeListener listener) { synchronized (lock) { if (isRemoved()) throw new IllegalStateException("node has been removed"); if (listener == null) throw new NullPointerException("listener is null"); if (preferenceListeners == null) preferenceListeners = new ArrayList(); preferenceListeners.add(listener); } // XXX }
6,426
private void flushNode(boolean sync) throws BackingStoreException { String[] keys = null; synchronized(lock) { if (sync) { syncSpi(); } else { flushSpi(); } keys = (String[]) childCache.keySet().toArray(new String[]{}); } if (keys != null) { for (int i = 0; i < keys.length; i++) { // Have to lock this node again to access the childCache AbstractPreferences subNode; synchronized(this) { subNode = (AbstractPreferences) childCache.get(keys[i]); } // The child could already have been removed from the cache if (subNode != null) { subNode.flushNode(sync); } } } }
private void flushNode(boolean sync) throws BackingStoreException { String[] keys = null; synchronized(lock) { if (sync) { syncSpi(); } else { flushSpi(); } keys = (String[]) childCache.keySet().toArray(new String[]{}); } if (keys != null) { for (int i = 0; i < keys.length; i++) { // Have to lock this node again to access the childCache AbstractPreferences subNode; synchronized(lock) { subNode = (AbstractPreferences) childCache.get(keys[i]); } // The child could already have been removed from the cache if (subNode != null) { subNode.flushNode(sync); } } } }
6,427
private void purge() throws BackingStoreException { // Make sure all children have an AbstractPreferences node in cache String children[] = childrenNamesSpi(); for (int i = 0; i < children.length; i++) { if (childCache.get(children[i]) == null) childCache.put(children[i], childSpi(children[i])); } // purge all children Iterator i = childCache.values().iterator(); while (i.hasNext()) { AbstractPreferences node = (AbstractPreferences) i.next(); synchronized(node) { node.purge(); } } // Cache is empty now childCache.clear(); // remove this node removeNodeSpi(); removed = true; // XXX - check for listeners }
private void purge() throws BackingStoreException { // Make sure all children have an AbstractPreferences node in cache String children[] = childrenNamesSpi(); for (int i = 0; i < children.length; i++) { if (childCache.get(children[i]) == null) childCache.put(children[i], childSpi(children[i])); } // purge all children Iterator i = childCache.values().iterator(); while (i.hasNext()) { AbstractPreferences node = (AbstractPreferences) i.next(); synchronized(node.lock) { node.purge(); } } // Cache is empty now childCache.clear(); // remove this node removeNodeSpi(); removed = true; // XXX - check for listeners }
6,429
public void putBoolean(String key, boolean value) { put(key, String.valueOf(value)); // XXX - Use when using 1.4 compatible Boolean // put(key, Boolean.toString(value)); }
public void putBoolean(String key, boolean value) { put(key, Boolean.toString(value)); // XXX - Use when using 1.4 compatible Boolean // put(key, Boolean.toString(value)); }
6,432
public void removeNode() throws BackingStoreException { // Check if it is a root node if (parent == null) throw new UnsupportedOperationException("Cannot remove root node"); synchronized(parent) { synchronized(this) { if (isRemoved()) throw new IllegalStateException("Node Removed"); purge(); } parent.childCache.remove(name); } }
public void removeNode() throws BackingStoreException { // Check if it is a root node if (parent == null) throw new UnsupportedOperationException("Cannot remove root node"); synchronized(parent) { synchronized(this) { if (isRemoved()) throw new IllegalStateException("Node Removed"); purge(); } parent.childCache.remove(name); } }
6,434
public void removeNodeChangeListener(NodeChangeListener listener) { // XXX }
public void removeNodeChangeListener(NodeChangeListener listener) { // XXX }
6,435
public void removePreferenceChangeListener (PreferenceChangeListener listener) { // XXX }
public void removePreferenceChangeListener (PreferenceChangeListener listener) { // XXX synchronized (lock) { if (isRemoved()) throw new IllegalStateException("node has been removed"); if (listener == null) throw new NullPointerException("listener is null"); if (preferenceListeners != null) preferenceListeners.remove(listener); } }
6,436
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,438
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,439
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger a; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,440
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if (l != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,441
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,442
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (a.bitLength() != 1) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (a.bitLength() != 1) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (a.bitLength() != 1) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (a.bitLength() != 1) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (a.bitLength() != 1) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (a.bitLength() != 1) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (a.bitLength() != 1) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,443
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,444
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,445
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { a = a.add(ONE); if (a.compareTo(bn) != 0) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { a = a.add(ONE); if (a.compareTo(bn) != 0) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { a = a.add(ONE); if (a.compareTo(bn) != 0) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { a = a.add(ONE); if (a.compareTo(bn) != 0) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? a = a.add(ONE); if (a.compareTo(bn) != 0) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { a = a.add(ONE); if (a.compareTo(bn) != 0) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } a = a.add(ONE); if (a.compareTo(bn) != 0) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,446
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,447
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,448
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); return true; BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); return false; // Not prime k = 1; else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); return false; // Not prime k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); return false; // Not prime // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); return false; // Failed, not prime // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); return false; // Failed, not prime // It worked (to the base primes[i]) if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true;
6,449
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,450
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,451
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,452
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,453
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,454
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,455
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,456
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,457
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
public static boolean passEulerCriterion(final BigInteger w) { // first check if it's already a known prime WeakReference obj = (WeakReference) knownPrimes.get(w); if (obj != null && w.equals(obj.get())) { if (DEBUG && debuglevel > 4) { debug("found in known primes"); } return true; } BigInteger w_minus_one = w.subtract(ONE); BigInteger e = w_minus_one; // l is the 3 least-significant bits of e int l = e.and(BigInteger.valueOf(7L)).intValue(); int j = 1; // Where to start in prime array for strong prime tests BigInteger A; int k; if ((l & 7) != 0) { e = e.shiftRight(1); A = TWO.modPow(e, w); if ((l & 7) == 6) { // bn == 7 mod 8, expect +1 if (A.bitCount() != 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #1..."); } return false; // Not prime } k = 1; } else { // bn == 3 or 5 mod 8, expect -1 == bn-1 A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #2..."); } return false; // Not prime } k = 1; if ((l & 4) != 0) { // bn == 5 mod 8, make odd for strong tests e = e.shiftRight(1); k = 2; } } } else { // bn == 1 mod 8, expect 2^((bn-1)/4) == +/-1 mod bn e = e.shiftRight(2); A = TWO.modPow(e, w); if (A.bitCount() == 1) { j = 0; // Re-do strong prime test to base 2 } else { A = A.add(ONE); if (!A.equals(w)) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #3..."); } return false; // Not prime } } // bnMakeOdd(n) = d * 2^s. Replaces n with d and returns s. k = e.getLowestSetBit(); e = e.shiftRight(k); k += 2; } // It's prime! Now go on to confirmation tests // Now, e = (bn-1)/2^k is odd. k >= 1, and has a given value with // probability 2^-k, so its expected value is 2. j = 1 in the usual case // when the previous test was as good as a strong prime test, but 1/8 of // the time, j = 0 because the strong prime test to the base 2 needs to // be re-done. //for (int i = j; i < SMALL_PRIME_COUNT; i++) { for (int i = j; i < 13; i++) { // try only the first 13 primes A = SMALL_PRIME[i]; A = A.modPow(e, w); if (A.bitCount() == 1) { continue; // Passed this test } l = k; while (true) { // A = A.add(ONE); // if (A.equals(w)) { // Was result bn-1? if (A.equals(w_minus_one)) { // Was result bn-1? break; // Prime } if (--l == 0) { // Reached end, not -1? luck? if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #4..."); } return false; // Failed, not prime } // This portion is executed, on average, once // A = A.subtract(ONE); // Put a back where it was A = A.modPow(TWO, w); if (A.bitCount() == 1) { if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " fails Euler criterion #5..."); } return false; // Failed, not prime } } // It worked (to the base primes[i]) } if (DEBUG && debuglevel > 4) { debug(w.toString(16) + " passes Euler criterion..."); } // store it in the known primes weak hash-map knownPrimes.put(w, new WeakReference(w)); return true; }
6,458
protected CompilerBytecodeVisitor createBytecodeVisitor(VmMethod method, CompiledMethod cm, NativeStream os, int level, boolean isBootstrap) { final InlineBytecodeVisitor cbv; final EntryPoints entryPoints = getEntryPoints(); cbv = new X86BytecodeVisitor(os, cm, isBootstrap, entryPoints, magicHelper, getTypeSizeInfo()); if (inlineMethods /*&& ((X86Assembler)os).isCode32()*/) { final VmClassLoader loader = method.getDeclaringClass().getLoader(); return new InliningBytecodeVisitor(entryPoints, cbv, loader); } else { return cbv; } }
protected CompilerBytecodeVisitor createBytecodeVisitor(VmMethod method, CompiledMethod cm, NativeStream os, int level, boolean isBootstrap) { final InlineBytecodeVisitor cbv; final EntryPoints entryPoints = getEntryPoints(); cbv = new X86BytecodeVisitor(os, cm, isBootstrap, entryPoints, magicHelper, getTypeSizeInfo()); if (inlineMethods /*&& ((X86Assembler)os).isCode32()*/) { final VmClassLoader loader = method.getDeclaringClass().getLoader(); return new OptimizingBytecodeVisitor(entryPoints, cbv, loader); } else { return cbv; } }
6,459
public void endDraggingFrame(JComponent f) {// super.endDraggingFrame(f); JInternalFrame frame = (JInternalFrame)f;// JDesktopPane desk = frame.getDesktopPane();// desk.repaint();// frame.validate();// frame.repaint(); ((Gui5250)frame.getContentPane()).getScreen().gg2d = null; System.out.println(" Endi dragging "); }
public void endDraggingFrame(JComponent f) {// super.endDraggingFrame(f); JInternalFrame frame = (JInternalFrame)f;// JDesktopPane desk = frame.getDesktopPane();// desk.repaint();// frame.validate();// frame.repaint(); ((Gui5250)frame.getContentPane()).getScreen().gg2d = null; }
6,460
public MyInternalFrame() { super("#" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable internalId = openFrameCount; //...Create the GUI and put it in the window... //...Then set the window size or call pack... setSize(300,300); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); } public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); } public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; displayMessage("Internal frame deactivated", e); } }); }
public MyInternalFrame() { super("#" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable internalId = openFrameCount; //...Create the GUI and put it in the window... //...Then set the window size or call pack... setSize(600,500); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); } public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); } public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; displayMessage("Internal frame deactivated", e); } }); }
6,461
public MyInternalFrame() { super("#" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable internalId = openFrameCount; //...Create the GUI and put it in the window... //...Then set the window size or call pack... setSize(300,300); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); } public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); } public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; displayMessage("Internal frame deactivated", e); } }); }
public MyInternalFrame() { super("#" + (++openFrameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable internalId = openFrameCount; //...Create the GUI and put it in the window... //...Then set the window size or call pack... setSize(300,300); //Set the window's location. setLocation(xOffset*openFrameCount, yOffset*openFrameCount); addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) {// displayMessage("Internal frame closing", e); disconnectMe(); } public void internalFrameClosed(InternalFrameEvent e) {// displayMessage("Internal frame closed", e); } public void internalFrameOpened(InternalFrameEvent e) {// displayMessage("Internal frame opened", e); } public void internalFrameIconified(InternalFrameEvent e) {// displayMessage("Internal frame iconified", e); } public void internalFrameDeiconified(InternalFrameEvent e) {// displayMessage("Internal frame deiconified", e); } public void internalFrameActivated(InternalFrameEvent e) {// displayMessage("Internal frame activated", e); activated = true; repaint(); } public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; } }); }
6,462
public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; displayMessage("Internal frame deactivated", e); }
public void internalFrameDeactivated(InternalFrameEvent e) { activated = false; }
6,464
public void update(Graphics g) { paint(g); System.out.println("update"); }
public void update(Graphics g) { paint(g); }
6,465
private void init() { // append more attributes attribOrder.add("upperErrorValue"); attribOrder.add("lowerErrorValue"); attribOrder.add("errorValue"); //set up the attribute hashtable key with the default initial value attribHash.put("upperErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("lowerErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("errorValue", new XMLAttribute(null, Constants.STRING_TYPE)); }
private void init() { // append more attributes attribOrder.add("upperErrorValue"); attribOrder.add("lowerErrorValue"); //set up the attribute hashtable key with the default initial value attribHash.put("upperErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("lowerErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("errorValue", new XMLAttribute(null, Constants.STRING_TYPE)); }
6,468
private void init() { // append more attributes attribOrder.add("upperErrorValue"); attribOrder.add("lowerErrorValue"); attribOrder.add("errorValue"); //set up the attribute hashtable key with the default initial value attribHash.put("upperErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("lowerErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("errorValue", new XMLAttribute(null, Constants.STRING_TYPE)); }
private void init() { // append more attributes attribOrder.add("upperErrorValue"); attribOrder.add("lowerErrorValue"); attribOrder.add("errorValue"); //set up the attribute hashtable key with the default initial value attribHash.put("upperErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("lowerErrorValue", new XMLAttribute(null, Constants.STRING_TYPE)); }
6,469
protected final boolean negotiate(byte abyte0[]) throws IOException { int i = 0; // from server negotiations if(abyte0[i] == IAC) { // -1 while(i < abyte0.length && abyte0[i++] == -1) switch(abyte0[i++]) { // we will not worry about what it WONT do case WONT: // -4 default: break; case DO: //-3 switch(abyte0[i]) { case TERMINAL_TYPE: // 24 baosp.write(IAC); baosp.write(WILL); baosp.write(TERMINAL_TYPE); writeByte(baosp.toByteArray()); baosp.reset(); break; case OPT_END_OF_RECORD: // 25 baosp.write(IAC); baosp.write(WILL); baosp.write(OPT_END_OF_RECORD); writeByte(baosp.toByteArray()); baosp.reset(); break; case TRANSMIT_BINARY: // 0 baosp.write(IAC); baosp.write(WILL); baosp.write(TRANSMIT_BINARY); writeByte(baosp.toByteArray()); baosp.reset(); break; case TIMING_MARK: // 6 rfc860// System.out.println("Timing Mark Received and notifying " +// "the server that we will not do it"); baosp.write(IAC); baosp.write(WONT); baosp.write(TIMING_MARK); writeByte(baosp.toByteArray()); baosp.reset(); break; case NEW_ENVIRONMENT: // 39 rfc1572 if (devName == null) { baosp.write(IAC); baosp.write(WONT); baosp.write(NEW_ENVIRONMENT); writeByte(baosp.toByteArray()); baosp.reset(); } else { System.out.println(devName); baosp.write(IAC); baosp.write(WILL); baosp.write(NEW_ENVIRONMENT); writeByte(baosp.toByteArray()); baosp.reset(); } break; default: // every thing else we will not do at this time baosp.write(IAC); baosp.write(WONT); baosp.write(abyte0[i]); // either writeByte(baosp.toByteArray()); baosp.reset(); break; } i++; break; case WILL: switch(abyte0[i]) { case OPT_END_OF_RECORD: // 25 baosp.write(IAC); baosp.write(DO); baosp.write(OPT_END_OF_RECORD); writeByte(baosp.toByteArray()); baosp.reset(); break; case TRANSMIT_BINARY: // '\0' baosp.write(IAC); baosp.write(DO); baosp.write(TRANSMIT_BINARY); writeByte(baosp.toByteArray()); baosp.reset(); break; } i++; break; case SB: // -6 if(abyte0[i] == NEW_ENVIRONMENT && abyte0[i + 1] == 1) { negNewEnvironment(); i++; } if(abyte0[i] == TERMINAL_TYPE && abyte0[i + 1] == 1) { baosp.write(IAC); baosp.write(SB); baosp.write(TERMINAL_TYPE); baosp.write(QUAL_IS); if(!support132) baosp.write((new String("IBM-3179-2")).getBytes()); else baosp.write((new String("IBM-3477-FC")).getBytes()); baosp.write(IAC); baosp.write(SE); writeByte(baosp.toByteArray()); baosp.reset(); i++; } i++; break; } return true; } else { return false; } }
protected final boolean negotiate(byte abyte0[]) throws IOException { int i = 0; // from server negotiations if(abyte0[i] == IAC) { // -1 while(i < abyte0.length && abyte0[i++] == -1) switch(abyte0[i++]) { // we will not worry about what it WONT do case WONT: // -4 default: break; case DO: //-3 switch(abyte0[i]) { case TERMINAL_TYPE: // 24 baosp.write(IAC); baosp.write(WILL); baosp.write(TERMINAL_TYPE); writeByte(baosp.toByteArray()); baosp.reset(); break; case OPT_END_OF_RECORD: // 25 baosp.write(IAC); baosp.write(WILL); baosp.write(OPT_END_OF_RECORD); writeByte(baosp.toByteArray()); baosp.reset(); break; case TRANSMIT_BINARY: // 0 baosp.write(IAC); baosp.write(WILL); baosp.write(TRANSMIT_BINARY); writeByte(baosp.toByteArray()); baosp.reset(); break; case TIMING_MARK: // 6 rfc860// System.out.println("Timing Mark Received and notifying " +// "the server that we will not do it"); baosp.write(IAC); baosp.write(WONT); baosp.write(TIMING_MARK); writeByte(baosp.toByteArray()); baosp.reset(); break; case NEW_ENVIRONMENT: // 39 rfc1572 if (devName == null) { baosp.write(IAC); baosp.write(WONT); baosp.write(NEW_ENVIRONMENT); writeByte(baosp.toByteArray()); baosp.reset(); } else { System.out.println(devName); baosp.write(IAC); baosp.write(WILL); baosp.write(NEW_ENVIRONMENT); writeByte(baosp.toByteArray()); baosp.reset(); } break; default: // every thing else we will not do at this time baosp.write(IAC); baosp.write(WONT); baosp.write(abyte0[i]); // either writeByte(baosp.toByteArray()); baosp.reset(); break; } while (++i < abyte0.length && abyte0[i + 1] != IAC); break; case WILL: switch(abyte0[i]) { case OPT_END_OF_RECORD: // 25 baosp.write(IAC); baosp.write(DO); baosp.write(OPT_END_OF_RECORD); writeByte(baosp.toByteArray()); baosp.reset(); break; case TRANSMIT_BINARY: // '\0' baosp.write(IAC); baosp.write(DO); baosp.write(TRANSMIT_BINARY); writeByte(baosp.toByteArray()); baosp.reset(); break; } while (++i < abyte0.length && abyte0[i + 1] != IAC); break; case SB: // -6 if(abyte0[i] == NEW_ENVIRONMENT && abyte0[i + 1] == 1) { negNewEnvironment(); while (++i < abyte0.length && abyte0[i + 1] != IAC); } if(abyte0[i] == TERMINAL_TYPE && abyte0[i + 1] == 1) { baosp.write(IAC); baosp.write(SB); baosp.write(TERMINAL_TYPE); baosp.write(QUAL_IS); if(!support132) baosp.write((new String("IBM-3179-2")).getBytes()); else baosp.write((new String("IBM-3477-FC")).getBytes()); baosp.write(IAC); baosp.write(SE); writeByte(baosp.toByteArray()); baosp.reset(); while (++i < abyte0.length && abyte0[i + 1] != IAC); } while (++i < abyte0.length && abyte0[i + 1] != IAC); break; } return true; } else { return false; } }
6,470
public void setInput(Object input) { setInput(input, false, false); }
public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) { setInput(input, false, false); }
6,472
public void setInput(Object input) { setInput(input, false, false); }
public void setInput(Object input) { Class[] okClasses = originatingProvider.getInputTypes(); if (okClasses == null) { if (!(input instanceof ImageInputStream)) throw new IllegalArgumentException(); } else { boolean classOk = false; for (int i = 0; i < okClasses.length; ++i) if (okClasses[i].isInstance(input)) classOk = true; if (!classOk) throw new IllegalArgumentException(); } this.input = input; this.seekForwardOnly = seekForwardOnly; this.ignoreMetadata = ignoreMetadata; this.minIndex = 0; }
6,473
protected String basicXMLWriter ( Writer outputWriter, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) throws java.io.IOException { //while writing out, attribHash should not be changed synchronized (attribHash) { 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; // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write( indent); // indent node if desired outputWriter.write("<" + nodeNameString); // print opening statement } // gather info about Attributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { int size = attribs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) attribs.get(i); outputWriter.write( " " + item.get("name") + "=\""); // this slows things down, should we use? writeOutAttribute(outputWriter, (String) item.get("value")); // outputWriter.write((String) item.get("value")); outputWriter.write( "\"" ); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { outputWriter.write( ">"); if ((Specification.getInstance().isPrettyXDFOutput()) && (pcdata == null)) outputWriter.write( Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { if (hasValueListCompactDescription && valueListXMLItemName.equals(item.get("name"))) { Iterator iter = valueListObjects.iterator(); while(iter.hasNext()) { ValueListInterface valueListObj = (ValueListInterface) iter.next(); // Grouping *may* differ between the values held in each ValueLists. To check we // if all valueListObjects are 'kosher' we use the first value in the values // list of each ValueListObj as a reference object and compare it to all other // values in that list (but not the lists of values in other ValueListObj). Yes, // this can be slow for large lists of values but is the correct thing to do. List values = valueListObj.getValues(); Value valueObj = (Value) values.get(0); // *sigh* Yes, we have to check that all values belong to // the same groups, or problems will arise in the output. Do that here. boolean canUseCompactValueDescription = true; Set firstValueGroups = valueObj.openGroupNodeHash; Iterator valueIter = values.iterator(); valueIter.next(); // no need to do first group while (valueIter.hasNext()) { Value thisValue = (Value) valueIter.next(); if (thisValue != null) { Set thisValuesGroups = thisValue.openGroupNodeHash; if (!firstValueGroups.equals(thisValuesGroups)) { // Note this comparison also does size too Log.infoln("Cant use short description for values because some values have differing groups! Using long description instead."); canUseCompactValueDescription = false; break; } } } if (canUseCompactValueDescription) { // use compact description indent = dealWithClosingGroupNodes((BaseObject) valueObj, outputWriter, indent); indent = dealWithOpeningGroupNodes((BaseObject) valueObj, outputWriter, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); // now print the valuelist itself valueListObj.toXMLWriter(outputWriter, newindent); } else { // use regular (long) method List objectList = (List) item.get("value"); indent = objectListToXMLWriter(outputWriter, objectList, indent); } } } else { // use regular method List objectList = (List) item.get("value"); indent = objectListToXMLWriter(outputWriter, objectList, indent); } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { indent = dealWithClosingGroupNodes(containedObj, outputWriter, indent); indent = dealWithOpeningGroupNodes(containedObj, outputWriter, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); containedObj.toXMLWriter(outputWriter, newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { outputWriter.write(entifyString(pcdata)); }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write(indent + Specification.getInstance().getPrettyXDFOutputIndentation()); outputWriter.write( "<" + noChildObjectNodeName + "/>"); if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write( Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputWriter, indent); if (Specification.getInstance().isPrettyXDFOutput() && pcdata == null) outputWriter.write( indent); if (!dontCloseNode) outputWriter.write( "</"+nodeNameString+">"); } } else { if (nodeNameString != null) { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) outputWriter.write( ">"); } else { // no sub-objects, just close this node outputWriter.write( "/>"); } } } return nodeNameString; } //synchronize }
protected String basicXMLWriter ( Writer outputWriter, String indent, boolean dontCloseNode, String newNodeNameString, String noChildObjectNodeName ) throws java.io.IOException { //while writing out, attribHash should not be changed synchronized (attribHash) { 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; // 1. open this node, print its simple XML attributes if (nodeNameString != null) { if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write( indent); // indent node if desired outputWriter.write("<" + nodeNameString); // print opening statement } // gather info about Attributes in this object/node Hashtable xmlInfo = getXMLInfo(); // 2. Print out string object XML attributes EXCEPT for the one that // matches PCDATAAttribute. ArrayList attribs = (ArrayList) xmlInfo.get("attribList"); // is synchronized here correct? synchronized(attribs) { int size = attribs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) attribs.get(i); outputWriter.write( " " + item.get("name") + "=\""); // this slows things down, should we use? writeOutAttribute(outputWriter, (String) item.get("value")); // outputWriter.write((String) item.get("value")); outputWriter.write( "\"" ); } } // 3. Print out Node PCData or Child Nodes as specified by object ref // XML attributes. The way this stuff occurs will also affect how we // close the node. ArrayList childObjs = (ArrayList) xmlInfo.get("childObjList"); String pcdata = (String) xmlInfo.get("PCDATA"); if ( childObjs.size() > 0 || pcdata != null || noChildObjectNodeName != null) { // close the opening tag if (nodeNameString != null) { outputWriter.write( ">"); if ((Specification.getInstance().isPrettyXDFOutput()) && (pcdata == null)) outputWriter.write( Constants.NEW_LINE); } // deal with object/list XML attributes, if any in our list int size = childObjs.size(); for (int i = 0; i < size; i++) { Hashtable item = (Hashtable) childObjs.get(i); if (item.get("type") == Constants.LIST_TYPE) { if (hasValueListCompactDescription && valueListXMLItemName.equals(item.get("name"))) { Iterator iter = valueListObjects.iterator(); while(iter.hasNext()) { ValueList valueListObj = (ValueList) iter.next(); // Grouping *may* differ between the values held in each ValueLists. To check we // if all valueListObjects are 'kosher' we use the first value in the values // list of each ValueListObj as a reference object and compare it to all other // values in that list (but not the lists of values in other ValueListObj). Yes, // this can be slow for large lists of values but is the correct thing to do. List values = valueListObj.getValues(); Value valueObj = (Value) values.get(0); // *sigh* Yes, we have to check that all values belong to // the same groups, or problems will arise in the output. Do that here. boolean canUseCompactValueDescription = true; Set firstValueGroups = valueObj.openGroupNodeHash; Iterator valueIter = values.iterator(); valueIter.next(); // no need to do first group while (valueIter.hasNext()) { Value thisValue = (Value) valueIter.next(); if (thisValue != null) { Set thisValuesGroups = thisValue.openGroupNodeHash; if (!firstValueGroups.equals(thisValuesGroups)) { // Note this comparison also does size too Log.infoln("Cant use short description for values because some values have differing groups! Using long description instead."); canUseCompactValueDescription = false; break; } } } if (canUseCompactValueDescription) { // use compact description indent = dealWithClosingGroupNodes((BaseObject) valueObj, outputWriter, indent); indent = dealWithOpeningGroupNodes((BaseObject) valueObj, outputWriter, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); // now print the valuelist itself valueListObj.toXMLWriter(outputWriter, newindent); } else { // use regular (long) method List objectList = (List) item.get("value"); indent = objectListToXMLWriter(outputWriter, objectList, indent); } } } else { // use regular method List objectList = (List) item.get("value"); indent = objectListToXMLWriter(outputWriter, objectList, indent); } } else if (item.get("type") == Constants.OBJECT_TYPE) { BaseObject containedObj = (BaseObject) item.get("value"); if (containedObj != null) { // can happen from pre-allocation of axis values, etc (?) // shouldnt this be synchronized too?? synchronized(containedObj) { indent = dealWithClosingGroupNodes(containedObj, outputWriter, indent); indent = dealWithOpeningGroupNodes(containedObj, outputWriter, indent); String newindent = indent + Specification.getInstance().getPrettyXDFOutputIndentation(); containedObj.toXMLWriter(outputWriter, newindent); } } } else { // error: weird type, actually shouldnt occur. Is this needed?? Log.errorln("Weird error: unknown XML attribute type for item:"+item); } } // print out PCDATA, if any if(pcdata != null) { outputWriter.write(entifyString(pcdata)); }; // if there are no PCDATA or child objects/nodes then // we print out noChildObjectNodeName and close the node if ( childObjs.size() == 0 && pcdata == null && noChildObjectNodeName != null) { if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write(indent + Specification.getInstance().getPrettyXDFOutputIndentation()); outputWriter.write( "<" + noChildObjectNodeName + "/>"); if (Specification.getInstance().isPrettyXDFOutput()) outputWriter.write( Constants.NEW_LINE); } // ok, now deal with closing the node if (nodeNameString != null) { indent = dealWithClosingGroupNodes((BaseObject) this, outputWriter, indent); if (Specification.getInstance().isPrettyXDFOutput() && pcdata == null) outputWriter.write( indent); if (!dontCloseNode) outputWriter.write( "</"+nodeNameString+">"); } } else { if (nodeNameString != null) { if (dontCloseNode) { // it may not have sub-objects, but we dont want to close it // (happens for group objects) outputWriter.write( ">"); } else { // no sub-objects, just close this node outputWriter.write( "/>"); } } } return nodeNameString; } //synchronize }
6,475
protected void setValueListObj (ValueListInterface valueListObj) { resetBaseValueListObjects(); addValueListObj(valueListObj); }
protected void setValueListObj (ValueList valueListObj) { resetBaseValueListObjects(); addValueListObj(valueListObj); }
6,476
protected void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { boolean editable = ((Boolean) event.getNewValue()).booleanValue(); // Changing the color only if the current background is an instance of // ColorUIResource is the behavior of the RI. if (textComponent.getBackground() instanceof ColorUIResource) textComponent.setBackground(editable ? background : inactiveBackground); } }
protected void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { // Changing the color only if the current background is an instance of // ColorUIResource is the behavior of the RI. if (textComponent.getBackground() instanceof ColorUIResource) textComponent.setBackground(editable ? background : inactiveBackground); } }
6,478
protected void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { boolean editable = ((Boolean) event.getNewValue()).booleanValue(); // Changing the color only if the current background is an instance of // ColorUIResource is the behavior of the RI. if (textComponent.getBackground() instanceof ColorUIResource) textComponent.setBackground(editable ? background : inactiveBackground); } }
protected void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("editable")) { boolean editable = ((Boolean) event.getNewValue()).booleanValue(); // Changing the color only if the current background is an instance of // ColorUIResource is the behavior of the RI. if (textComponent.getBackground() instanceof ColorUIResource) { Color c = null; Color old = textComponent.getBackground(); String prefix = getPropertyPrefix(); if (! textComponent.isEnabled()) c = SharedUIDefaults.getColor(prefix + ".disabledBackground"); if (c == null && ! textComponent.isEditable()) c = SharedUIDefaults.getColor(prefix + ".inactiveBackground"); if (c == null) c = SharedUIDefaults.getColor(prefix + ".background"); if (c != null && c != old) { textComponent.setBackground(c); } } } }
6,479
private void checkDataArrayBounds (int longIndex, int shortIndex, int type) throws SetDataException { // Does the location exist yet? If not, create the primative arrays // that lie along the short axis int shortAxisSize = getShortAxis().getLength(); // is the long array too small? if (longDataArray.size() < (longIndex+1)) { int maxDeclLongArraySize = getMaxLongArraySize(); // should be held in private var int expandSize = longIndex > maxDeclLongArraySize ? longIndex : maxDeclLongArraySize; expandSize *= expandFactor; // add in additional amount to prevent us from doing this too much expandLongArray(expandSize); } // is the short array too small? has it been init'd even yet? // we perform checks here.. if (longDataArray.get(longIndex) == null) { // init/create the short array longDataArray.set( longIndex, new byte[shortAxisSize]); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, new double [shortAxisSize]); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, new int [shortAxisSize]); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, new short [shortAxisSize]); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, new long [shortAxisSize]); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, new String [shortAxisSize]); } } else { int currentShortAxisSize = getLongDataArraySize(longIndex, type); // requested short axis location not exist? if (currentShortAxisSize < shortIndex) { // should flag the user that need to add AxisValue first if (shortIndex > shortAxisSize) { Log.errorln ("Error: axis lacks an AxisValue at location requested in setData()."); throw new SetDataException(); } else { // add in short axis location to local short array(s) int newsize = shortIndex; newsize *= expandFactor; // expand short axis by expandFactor longDataArray.set(longIndex, expandArray((byte []) longDataArray.get(longIndex), newsize)); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((double[]) longDataArray.get(longIndex+1), newsize)); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((int[]) longDataArray.get(longIndex+1), newsize)); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((short[]) longDataArray.get(longIndex+1), newsize)); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((long []) longDataArray.get(longIndex+1), newsize)); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((String []) longDataArray.get(longIndex+1), newsize)); } } } } }
private void checkDataArrayBounds (int longIndex, int shortIndex, int type) throws SetDataException { // Does the location exist yet? If not, create the primative arrays // that lie along the short axis int shortAxisSize = getShortAxis().getLength(); // is the long array too small? if (longDataArray.size() < (longIndex+1)) { int maxDeclLongArraySize = getMaxLongArraySize(); // should be held in private var int expandSize = longIndex > maxDeclLongArraySize ? longIndex : maxDeclLongArraySize; expandSize *= expandFactor; // add in additional amount to prevent us from doing this too much expandLongArray(expandSize); } // is the short array too small? has it been init'd even yet? // we perform checks here.. if (longDataArray.get(longIndex) == null) { // init/create the short array longDataArray.set( longIndex, new byte[shortAxisSize]); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, new double [shortAxisSize]); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, new int [shortAxisSize]); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, new short [shortAxisSize]); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, new long [shortAxisSize]); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, new String [shortAxisSize]); } } else { int currentShortAxisSize = getLongDataArraySize(longIndex, type); // requested short axis location not exist? if (currentShortAxisSize < shortIndex) { // should flag the user that need to add AxisValue first if (shortIndex > shortAxisSize) { Log.errorln ("Error: axis lacks an AxisValue at location requested in setData()."); throw new SetDataException(); } else { // add in short axis location to local short array(s) int newsize = shortIndex+1; newsize *= expandFactor; // expand short axis by expandFactor longDataArray.set(longIndex, expandArray((byte []) longDataArray.get(longIndex), newsize)); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((double[]) longDataArray.get(longIndex+1), newsize)); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((int[]) longDataArray.get(longIndex+1), newsize)); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((short[]) longDataArray.get(longIndex+1), newsize)); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((long []) longDataArray.get(longIndex+1), newsize)); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((String []) longDataArray.get(longIndex+1), newsize)); } } } } }
6,480
private void expandLongArray (int newsize) { int currentSize = longDataArray.size(); int additionalCapacity = (newsize - currentSize) * 2; // mult by 2 to allow for shadow byte array if (additionalCapacity > 0) {Log.debugln("Expanding Long array size to "+newsize+" from "+currentSize +" (add capacity is "+additionalCapacity+")"); List moreArray = Collections.synchronizedList(new ArrayList(additionalCapacity)); for (int i = 0; i < additionalCapacity; i++) { moreArray.add(null); // populate with nulls } longDataArray.addAll(moreArray); } }
private void expandLongArray (int newsize) { int currentSize = longDataArray.size(); int additionalCapacity = (newsize - currentSize) * 2; // mult by 2 to allow for shadow byte array if (additionalCapacity > 0) {Log.debugln(" DataCube is expanding internal LongDataArray size to "+(newsize*2)+" from "+(currentSize*2)+" (added capacity is:"+additionalCapacity+")"); List moreArray = Collections.synchronizedList(new ArrayList(additionalCapacity)); for (int i = 0; i < additionalCapacity; i++) { moreArray.add(null); // populate with nulls } longDataArray.addAll(moreArray); } }
6,481
public Object getData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
public Object getData (Locator locator) throws NoDataException { int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
6,482
public double getDoubleData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
public double getDoubleData (Locator locator) throws NoDataException { int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
6,483
public int getIntData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getInt(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
public int getIntData (Locator locator) throws NoDataException { int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getInt(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
6,484
public long getLongData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getLong(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
public long getLongData (Locator locator) throws NoDataException { int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getLong(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
6,485
private AxisInterface getShortAxis () { AxisInterface shortAxis = null; List axisList = parentArray.getAxes(); if (axisList.size() > 1) { shortAxis = (AxisInterface) parentArray.getAxes().get(1); } return shortAxis; }
private AxisInterface getShortAxis () { AxisInterface shortAxis = null; List axisList = parentArray.getAxes(); if (axisList.size() > 1) { shortAxis = (AxisInterface) axisList.get(1); } return shortAxis; }
6,486
public short getShortData (Locator locator) throws NoDataException { List axisList = parentArray.getAxes(); int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getShort(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
public short getShortData (Locator locator) throws NoDataException { int longIndex = getLongArrayIndex(locator); int shortIndex = getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getShort(longDataArray.get(longIndex), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
6,487
public void reset() { Log.errorln("in DataCube, reset(), method is empty needs to be implemented!"); // reset the longDataArray, will free all related shortDataArrays. // What else needs to be done? // this.longDataArray = Collections.synchronizedList(new ArrayList()); }
public void reset() { Log.debugln("in DataCube, called reset()"); // reset the longDataArray, will free all related shortDataArrays. // What else needs to be done? // this.longDataArray = Collections.synchronizedList(new ArrayList()); }
6,488
public void setBorderPainted(boolean painted) { if (painted != paintBorder) { boolean oldPainted = paintBorder; paintBorder = painted; firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, oldPainted, paintBorder); } }
public void setBorderPainted(boolean painted) { if (painted != paintBorder) { boolean oldPainted = paintBorder; paintBorder = painted; firePropertyChange("borderPainted", oldPainted, paintBorder); } }
6,490
public void setIndeterminate(boolean newValue) { if (indeterminate != newValue) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange(INDETERMINATE_CHANGED_PROPERTY, olddeter, indeterminate); } }
public void setIndeterminate(boolean newValue) { if (indeterminate != newValue) { boolean olddeter = indeterminate; indeterminate = newValue; firePropertyChange("indeterminate", olddeter, indeterminate); } }
6,491
public void setOrientation(int orientation) { if (orientation != VERTICAL && orientation != HORIZONTAL) throw new IllegalArgumentException("orientation must be one of VERTICAL or HORIZONTAL"); if (this.orientation != orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange(ORIENTATION_CHANGED_PROPERTY, oldOrientation, this.orientation); } }
public void setOrientation(int orientation) { if (orientation != VERTICAL && orientation != HORIZONTAL) throw new IllegalArgumentException("orientation must be one of VERTICAL or HORIZONTAL"); if (this.orientation != orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange("orientation", oldOrientation, this.orientation); } }
6,492
public void setString(String string) { if (((string == null || progressString == null) && string != progressString) || (string != null && ! string.equals(progressString))) { String oldString = progressString; progressString = string; firePropertyChange(STRING_CHANGED_PROPERTY, oldString, progressString); } }
public void setString(String string) { if (((string == null || progressString == null) && string != progressString) || (string != null && ! string.equals(progressString))) { String oldString = progressString; progressString = string; firePropertyChange("string", oldString, progressString); } }
6,493
public void setStringPainted(boolean painted) { if (paintString != painted) { boolean oldPainted = paintString; paintString = painted; firePropertyChange(STRING_PAINTED_CHANGED_PROPERTY, oldPainted, paintString); } }
public void setStringPainted(boolean painted) { if (paintString != painted) { boolean oldPainted = paintString; paintString = painted; firePropertyChange("stringPainted", oldPainted, paintString); } }
6,494
public static Rectangle calculateInnerArea(JComponent c, Rectangle r) { Rectangle b = getLocalBounds(c); return calculateInsetArea(b, c.getInsets(), r); }
public static Rectangle calculateInnerArea(JComponent c, Rectangle r) { Rectangle b = getLocalBounds(c); if (r == null) r = new Rectangle(); Insets i = c.getInsets(); r.x = b.x + i.left; r.width = b.width - i.left - i.right; r.y = b.y + i.top; r.height = b.height - i.top - i.bottom; return r; }
6,497
public static ComponentUI createUI(JComponent component) { if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalComboBoxUI instance; if (o == null) { instance = new MetalComboBoxUI(); instances.put(component, instance); } else instance = (MetalComboBoxUI) o; return instance; }
public static ComponentUI createUI(JComponent component) { if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalComboBoxUI instance; if (o == null) { instance = new MetalComboBoxUI(); instances.put(component, instance); } else instance = (MetalComboBoxUI) o; return instance; }
6,498
public String templateNotation(String strEndian, String strEncoding) { if (numOfBytes() >4) { Log.error("XDF::BinaryInteger cant handle > 32 bit Integer Numbers"); Log.error("returning null"); return null; } if (!Utility.isValidEndian(strEndian)) { Log.error("not a valid endian, returning null"); return null; } // we hardwired 'BigEndian" response here. Bad! if (strEndian.equals(Constants.BIG_ENDIAN)) return "N"; else return "V"; }
public String templateNotation(String strEndian, String strEncoding) { if (numOfBytes() >4) { Log.error("BinaryInteger cant handle > 32 bit Integer Numbers"); Log.error("returning null"); return null; } if (!Utility.isValidEndian(strEndian)) { Log.error("not a valid endian, returning null"); return null; } // we hardwired 'BigEndian" response here. Bad! if (strEndian.equals(Constants.BIG_ENDIAN)) return "N"; else return "V"; }
6,499
public GroupDescriptor(int groupNr, Ext2FileSystem fs) throws IOException{ //read the group descriptors from the main copy in block group 0 byte[] blockData = fs.getBlock( fs.getSuperblock().getFirstDataBlock() + 1); byte[] data = new byte[GROUPDESCRIPTOR_LENGTH]; System.arraycopy(blockData, 0, data, 0, GROUPDESCRIPTOR_LENGTH); this.groupNr = groupNr; this.fs = fs; setDirty(false); log.setLevel(Level.DEBUG); }
public GroupDescriptor(int groupNr, Ext2FileSystem fs) throws IOException{ //read the group descriptors from the main copy in block group 0 byte[] blockData = fs.getBlock( fs.getSuperblock().getFirstDataBlock() + 1); byte[] data = new byte[GROUPDESCRIPTOR_LENGTH]; System.arraycopy(blockData, 0, data, 0, GROUPDESCRIPTOR_LENGTH); this.groupNr = groupNr; this.fs = fs; setDirty(false); log.setLevel(Level.DEBUG); }
6,500
public org.omg.CORBA.portable.InputStream create_input_stream() { if (has instanceof universalHolder) { universalHolder u = (universalHolder) has; return u.getInputStream(); } else { cdrBufOutput out = new cdrBufOutput(); out.setOrb(orb); write_value(out); cdrBufInput in = new cdrBufInput(out.buffer.toByteArray()); in.setOrb(orb); return in; } }
public org.omg.CORBA.portable.InputStream create_input_stream() { if (has instanceof universalHolder) { universalHolder u = (universalHolder) has; return u.getInputStream(); } else { cdrBufOutput out = new cdrBufOutput(); out.setOrb(orb); write_value(out); cdrBufInput in = new cdrBufInput(out.buffer.toByteArray()); in.setOrb(orb); return in; } }
6,501
public org.omg.CORBA.portable.InputStream create_input_stream() { if (has instanceof universalHolder) { universalHolder u = (universalHolder) has; return u.getInputStream(); } else { cdrBufOutput out = new cdrBufOutput(); out.setOrb(orb); write_value(out); cdrBufInput in = new cdrBufInput(out.buffer.toByteArray()); in.setOrb(orb); return in; } }
public org.omg.CORBA.portable.InputStream create_input_stream() { if (has instanceof universalHolder) { universalHolder u = (universalHolder) has; return u.getInputStream(); else { cdrBufOutput out = new cdrBufOutput(); out.setOrb(orb); write_value(out); cdrBufInput in = new cdrBufInput(out.buffer.toByteArray()); in.setOrb(orb); return in;
6,502
public void insert_Value(Serializable x, TypeCode c_typecode) { if (typecode != null && typecode.kind() == TCKind.tk_value_box) { has = new gnuValueHolder(x, typecode); } else { type(typecode); insert_Value(x); } }
public void insert_Value(Serializable x, TypeCode c_typecode) { if (typecode != null && typecode.kind() == TCKind.tk_value_box) { has = new gnuValueHolder(x, typecode); } else { type(typecode); insert_Value(x); } }
6,503
public void insert_Value(Serializable x, TypeCode c_typecode) { if (typecode != null && typecode.kind() == TCKind.tk_value_box) { has = new gnuValueHolder(x, typecode); } else { type(typecode); insert_Value(x); } }
public void insert_Value(Serializable x, TypeCode c_typecode) { if (typecode != null && typecode.kind() == TCKind.tk_value_box) { has = new gnuValueHolder(x, typecode); else { type(typecode); insert_Value(x);
6,504
public ConnectException(String message) { super(message); }
public ConnectException() { super(message); }
6,505
public ConnectException(String message) { super(message); }
public ConnectException(String message) { }
6,506
private JPanel pageOne () throws Exception { contentPane = new JPanel(); contentPane.setLayout(new BorderLayout()); statusBar.setText(" "); statusBar.setBorder(BorderFactory.createEtchedBorder()); spoolPanel.setLayout(new BorderLayout()); contentPane.add(spoolPanel, BorderLayout.CENTER); contentPane.add(statusBar, BorderLayout.SOUTH); // create the labels to be used for the spooled file data labelSpooledFile.setText(LangTool.getString("spool.labelSpooledFile")); labelJobName.setText(LangTool.getString("spool.labelJobName")); labelUser.setText(LangTool.getString("spool.labelJobUser")); labelNumber.setText(LangTool.getString("spool.labelJobNumber")); labelFileNumber.setText(LangTool.getString("spool.labelSpoolNumber")); labelSystem.setText(LangTool.getString("spool.labelSystem")); labelPages.setText(LangTool.getString("spool.labelPages")); spoolData.setLayout(new AlignLayout(2,5,5)); spoolData.setBorder(BorderFactory.createTitledBorder( LangTool.getString("spool.labelSpoolInfo"))); // create the data fields to be used for the spooled file data spooledFile.setText(splfile.getName()); jobName.setText(splfile.getJobName()); user.setText(splfile.getJobUser()); spooledFileNumber.setText(Integer.toString(splfile.getNumber())); number.setText(splfile.getJobNumber()); systemName.setText(splfile.getSystem().getSystemName()); pages.setText(splfile.getIntegerAttribute(splfile.ATTR_PAGES).toString()); spoolData.add(labelSystem, null); spoolData.add(systemName, null); spoolData.add(labelSpooledFile, null); spoolData.add(spooledFile, null); spoolData.add(labelJobName, null); spoolData.add(jobName, null); spoolData.add(labelUser, null); spoolData.add(user, null); spoolData.add(labelNumber, null); spoolData.add(number, null); spoolData.add(labelFileNumber, null); spoolData.add(spooledFileNumber, null); spoolData.add(labelPages, null); spoolData.add(pages, null); spoolPanel.add(spoolOptions, BorderLayout.SOUTH); // set the spool export panel spoolPanel.add(spoolData, BorderLayout.CENTER); spoolOptions.setLayout(new BorderLayout()); JPanel spoolInfo = new JPanel(); AlignLayout alignMe2 = new AlignLayout(3,5,5); spoolInfo.setLayout(alignMe2); spoolInfo.setBorder(BorderFactory.createTitledBorder( LangTool.getString("spool.labelExportInfo"))); cvtType = new JComboBox(); cvtType.addItem(LangTool.getString("spool.toPDF")); cvtType.addItem(LangTool.getString("spool.toText"));// cvtType.addItemListener(new java.awt.event.ItemListener() {// public void itemStateChanged(ItemEvent e) {// // if (((String)cvtType.getSelectedItem()).equals(// // LangTool.getString("spool.toText"))) {// // twoText.setVisible(true);// // twoPDF.setVisible(false);// // }// // else {// // twoText.setVisible(false);// // twoPDF.setVisible(true);// // }// }// }); spoolInfo.add(new JLabel(LangTool.getString("spool.labelFormat"))); spoolInfo.add(cvtType); spoolInfo.add(new JLabel("")); pc = new JRadioButton(LangTool.getString("spool.labelPCPath")); pcPathInfo = new JTextField(30); pcSave = new JButton("..."); pcSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { getPCFile(); } }); spoolInfo.add(pc); spoolInfo.add(pcPathInfo); spoolInfo.add(pcSave); ifs = new JRadioButton(LangTool.getString("spool.labelIFSPath")); ifsPathInfo = new JTextField(30); ifsSave = new JButton("..."); ifsSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { getIFSFile(); } }); spoolInfo.add(ifs); spoolInfo.add(ifsPathInfo); spoolInfo.add(ifsSave); email = new JRadioButton(LangTool.getString("spool.labelEmail")); spoolInfo.add(email); spoolInfo.add(new JLabel("")); spoolInfo.add(new JLabel("")); ButtonGroup bg = new ButtonGroup(); bg.add(pc); bg.add(ifs); bg.add(email); pc.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { doItemStateChanged(e); } }); ifs.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { doItemStateChanged(e); } }); email.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { doItemStateChanged(e); } }); pc.setSelected(true); spoolOptions.add(spoolInfo,BorderLayout.CENTER); return contentPane; }
private JPanel pageOne () throws Exception { contentPane = new JPanel(); contentPane.setLayout(new BorderLayout()); statusBar.setText(" "); statusBar.setBorder(BorderFactory.createEtchedBorder()); spoolPanel.setLayout(new BorderLayout()); contentPane.add(spoolPanel, BorderLayout.CENTER); contentPane.add(statusBar, BorderLayout.SOUTH); // create the labels to be used for the spooled file data labelSpooledFile.setText(LangTool.getString("spool.labelSpooledFile")); labelJobName.setText(LangTool.getString("spool.labelJobName")); labelUser.setText(LangTool.getString("spool.labelJobUser")); labelNumber.setText(LangTool.getString("spool.labelJobNumber")); labelFileNumber.setText(LangTool.getString("spool.labelSpoolNumber")); labelSystem.setText(LangTool.getString("spool.labelSystem")); labelPages.setText(LangTool.getString("spool.labelPages")); spoolData.setLayout(new AlignLayout(2,5,5)); spoolData.setBorder(BorderFactory.createTitledBorder( LangTool.getString("spool.labelSpoolInfo"))); // create the data fields to be used for the spooled file data spooledFile.setText(splfile.getName()); jobName.setText(splfile.getJobName()); user.setText(splfile.getJobUser()); spooledFileNumber.setText(Integer.toString(splfile.getNumber())); number.setText(splfile.getJobNumber()); systemName.setText(splfile.getSystem().getSystemName()); pages.setText(splfile.getIntegerAttribute(SpooledFile.ATTR_PAGES).toString()); spoolData.add(labelSystem, null); spoolData.add(systemName, null); spoolData.add(labelSpooledFile, null); spoolData.add(spooledFile, null); spoolData.add(labelJobName, null); spoolData.add(jobName, null); spoolData.add(labelUser, null); spoolData.add(user, null); spoolData.add(labelNumber, null); spoolData.add(number, null); spoolData.add(labelFileNumber, null); spoolData.add(spooledFileNumber, null); spoolData.add(labelPages, null); spoolData.add(pages, null); spoolPanel.add(spoolOptions, BorderLayout.SOUTH); // set the spool export panel spoolPanel.add(spoolData, BorderLayout.CENTER); spoolOptions.setLayout(new BorderLayout()); JPanel spoolInfo = new JPanel(); AlignLayout alignMe2 = new AlignLayout(3,5,5); spoolInfo.setLayout(alignMe2); spoolInfo.setBorder(BorderFactory.createTitledBorder( LangTool.getString("spool.labelExportInfo"))); cvtType = new JComboBox(); cvtType.addItem(LangTool.getString("spool.toPDF")); cvtType.addItem(LangTool.getString("spool.toText"));// cvtType.addItemListener(new java.awt.event.ItemListener() {// public void itemStateChanged(ItemEvent e) {// // if (((String)cvtType.getSelectedItem()).equals(// // LangTool.getString("spool.toText"))) {// // twoText.setVisible(true);// // twoPDF.setVisible(false);// // }// // else {// // twoText.setVisible(false);// // twoPDF.setVisible(true);// // }// }// }); spoolInfo.add(new JLabel(LangTool.getString("spool.labelFormat"))); spoolInfo.add(cvtType); spoolInfo.add(new JLabel("")); pc = new JRadioButton(LangTool.getString("spool.labelPCPath")); pcPathInfo = new JTextField(30); pcSave = new JButton("..."); pcSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { getPCFile(); } }); spoolInfo.add(pc); spoolInfo.add(pcPathInfo); spoolInfo.add(pcSave); ifs = new JRadioButton(LangTool.getString("spool.labelIFSPath")); ifsPathInfo = new JTextField(30); ifsSave = new JButton("..."); ifsSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { getIFSFile(); } }); spoolInfo.add(ifs); spoolInfo.add(ifsPathInfo); spoolInfo.add(ifsSave); email = new JRadioButton(LangTool.getString("spool.labelEmail")); spoolInfo.add(email); spoolInfo.add(new JLabel("")); spoolInfo.add(new JLabel("")); ButtonGroup bg = new ButtonGroup(); bg.add(pc); bg.add(ifs); bg.add(email); pc.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { doItemStateChanged(e); } }); ifs.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { doItemStateChanged(e); } }); email.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { doItemStateChanged(e); } }); pc.setSelected(true); spoolOptions.add(spoolInfo,BorderLayout.CENTER); return contentPane; }
6,507
protected KeySelectionManager createDefaultKeySelectionManager() { return null; }
protected KeySelectionManager createDefaultKeySelectionManager() { return new DefaultKeySelectionManager(); }
6,509
public KeySelectionManager getKeySelectionManager() { return null; }
public KeySelectionManager getKeySelectionManager() { return keySelectionManager; }
6,510
public void processKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) setPopupVisible(false); else if (keySelectionManager != null) { int i = keySelectionManager.selectionForKey(e.getKeyChar(), getModel()); if (i >= 0) setSelectedIndex(i); else super.processKeyEvent(e); } else super.processKeyEvent(e); }
public void processKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) setPopupVisible(false); else if (keySelectionManager != null) { int i = keySelectionManager.selectionForKey(e.getKeyChar(), getModel()); if (i >= 0) setSelectedIndex(i); else super.processKeyEvent(e); } else super.processKeyEvent(e); }
6,511
public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dashPhase) { if (width < 0 || miterlimit < 1.0f || cap < CAP_BUTT || cap > CAP_SQUARE || join < JOIN_MITER || join > JOIN_BEVEL) throw new IllegalArgumentException(); this.width = width; this.cap = cap; this.join = join; limit = miterlimit; this.dash = dash == null ? null : (float[]) dash.clone(); phase = dashPhase; }
public BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dashPhase) { if (width < 0 || miterlimit < 1.0f || cap < CAP_BUTT || cap > CAP_SQUARE || join < JOIN_MITER || join > JOIN_BEVEL) throw new IllegalArgumentException(); this.width = width; this.cap = cap; this.join = join; limit = miterlimit; this.dash = dash == null ? null : (float[]) dash.clone(); phase = dashPhase; }
6,515
createDragGestureRecognizer(Class recognizer, Component c, int actions, DragGestureListener dgl) { return Toolkit.getDefaultToolkit () .createDragGestureRecognizer (recognizer, this, c, actions, dgl); }
createDragGestureRecognizer(Class recognizer, Component c, int actions, DragGestureListener dgl) { DragGestureRecognizer dgr; dgr = Toolkit.getDefaultToolkit () .createDragGestureRecognizer (recognizer, this, c, actions, dgl); }
6,516
public static DragSource getDefaultDragSource() { return null; }
public static DragSource getDefaultDragSource() { return new DragSource(); }
6,518
public static FlavorMap getDefaultFlavorMap () { if (defaultFlavorMap == null) defaultFlavorMap = new SystemFlavorMap (); return defaultFlavorMap; }
public static FlavorMap getDefaultFlavorMap () { if (defaultFlavorMap == null) defaultFlavorMap = new SystemFlavorMap (); return defaultFlavorMap; }
6,519
public static FlavorMap getDefaultFlavorMap () { if (defaultFlavorMap == null) defaultFlavorMap = new SystemFlavorMap (); return defaultFlavorMap; }
public static FlavorMap getDefaultFlavorMap () { if (defaultFlavorMap == null) defaultFlavorMap = new SystemFlavorMap (); if (classLoader == null) { classLoader = ClassLoader.getSystemClassLoader(); } synchronized(systemFlavorMaps) { FlavorMap map = (FlavorMap) systemFlavorMaps.get(classLoader); if (map == null) { map = new SystemFlavorMap(); systemFlavorMaps.put(classLoader, map); } return map; } }
6,520
public void layoutContainer(Container c) { if (splitPane.isOneTouchExpandable()) { changeButtonOrientation(); positionButtons(); } }
public void layoutContainer(Container c) { if (splitPane.isOneTouchExpandable()) { changeButtonOrientation(); positionButtons(); } }
6,521
public void mousePressed(MouseEvent e) { if (splitPane.isOneTouchExpandable()) { if (e.getSource() == leftButton) { currentDividerLocation--; if (currentDividerLocation < 0) currentDividerLocation = 0; moveDividerTo(currentDividerLocation); return; } else if (e.getSource() == rightButton) { currentDividerLocation++; if (currentDividerLocation > 2) currentDividerLocation = 2; moveDividerTo(currentDividerLocation); return; } } isDragging = true; currentDividerLocation = 1; if (orientation == JSplitPane.HORIZONTAL_SPLIT) dragger = new DragController(e); else dragger = new VerticalDragController(e); prepareForDragging(); }
public void mousePressed(MouseEvent e) { if (splitPane.isOneTouchExpandable()) { if (e.getSource() == leftButton) { currentDividerLocation--; if (currentDividerLocation < 0) currentDividerLocation = 0; moveDividerTo(currentDividerLocation); return; } else if (e.getSource() == rightButton) { currentDividerLocation++; if (currentDividerLocation > 2) currentDividerLocation = 2; moveDividerTo(currentDividerLocation); return; } } isDragging = true; currentDividerLocation = 1; if (orientation == JSplitPane.HORIZONTAL_SPLIT) dragger = new DragController(e); else dragger = new VerticalDragController(e); prepareForDragging(); }
6,522
protected JButton createLeftOneTouchButton() { int dir = SwingConstants.WEST; if (orientation == JSplitPane.VERTICAL_SPLIT) dir = SwingConstants.NORTH; JButton button = new BasicArrowButton(dir); button.setBorder(null); return button; }
protected JButton createLeftOneTouchButton() { int dir = SwingConstants.WEST; if (orientation == JSplitPane.VERTICAL_SPLIT) dir = SwingConstants.NORTH; JButton button = new BasicArrowButton(dir); button.setBorder(null); return button; }
6,524
protected JButton createRightOneTouchButton() { int dir = SwingConstants.EAST; if (orientation == JSplitPane.VERTICAL_SPLIT) dir = SwingConstants.SOUTH; JButton button = new BasicArrowButton(dir); button.setBorder(null); return button; }
protected JButton createRightOneTouchButton() { int dir = SwingConstants.EAST; if (orientation == JSplitPane.VERTICAL_SPLIT) dir = SwingConstants.SOUTH; JButton button = new BasicArrowButton(dir); button.setBorder(null); return button; }
6,525
public Dimension getPreferredSize() { return getLayout().preferredLayoutSize(this); }
public Dimension getPreferredSize() { Dimension d; if (orientation == JSplitPane.HORIZONTAL_SPLIT) d = new Dimension(getDividerSize(), 1); else d = new Dimension(1, getDividerSize()); return d; }
6,526
protected void oneTouchExpandableChanged() { if (splitPane.isOneTouchExpandable()) { leftButton = createLeftOneTouchButton(); rightButton = createRightOneTouchButton(); add(leftButton); add(rightButton); leftButton.addMouseListener(mouseHandler); rightButton.addMouseListener(mouseHandler); // Set it to 1. currentDividerLocation = 1; } else { if (leftButton != null && rightButton != null) { leftButton.removeMouseListener(mouseHandler); rightButton.removeMouseListener(mouseHandler); remove(leftButton); remove(rightButton); leftButton = null; rightButton = null; } } layout(); repaint(); }
protected void oneTouchExpandableChanged() { if (splitPane.isOneTouchExpandable()) { leftButton = createLeftOneTouchButton(); rightButton = createRightOneTouchButton(); add(leftButton); add(rightButton); leftButton.addMouseListener(mouseHandler); rightButton.addMouseListener(mouseHandler); // Set it to 1. currentDividerLocation = 1; } else { if (leftButton != null && rightButton != null) { leftButton.removeMouseListener(mouseHandler); rightButton.removeMouseListener(mouseHandler); remove(leftButton); remove(rightButton); leftButton = null; rightButton = null; } } layout(); repaint(); }
6,527
protected void oneTouchExpandableChanged() { if (splitPane.isOneTouchExpandable()) { leftButton = createLeftOneTouchButton(); rightButton = createRightOneTouchButton(); add(leftButton); add(rightButton); leftButton.addMouseListener(mouseHandler); rightButton.addMouseListener(mouseHandler); // Set it to 1. currentDividerLocation = 1; } else { if (leftButton != null && rightButton != null) { leftButton.removeMouseListener(mouseHandler); rightButton.removeMouseListener(mouseHandler); remove(leftButton); remove(rightButton); leftButton = null; rightButton = null; } } layout(); repaint(); }
protected void oneTouchExpandableChanged() { if (splitPane.isOneTouchExpandable()) { leftButton = createLeftOneTouchButton(); rightButton = createRightOneTouchButton(); add(leftButton); add(rightButton); leftButton.addMouseListener(mouseHandler); rightButton.addMouseListener(mouseHandler); // Set it to 1. currentDividerLocation = 1; } else { if (leftButton != null && rightButton != null) { leftButton.removeMouseListener(mouseHandler); rightButton.removeMouseListener(mouseHandler); remove(leftButton); remove(rightButton); leftButton = null; rightButton = null; } } layout(); repaint(); }
6,528
protected void oneTouchExpandableChanged() { if (splitPane.isOneTouchExpandable()) { leftButton = createLeftOneTouchButton(); rightButton = createRightOneTouchButton(); add(leftButton); add(rightButton); leftButton.addMouseListener(mouseHandler); rightButton.addMouseListener(mouseHandler); // Set it to 1. currentDividerLocation = 1; } else { if (leftButton != null && rightButton != null) { leftButton.removeMouseListener(mouseHandler); rightButton.removeMouseListener(mouseHandler); remove(leftButton); remove(rightButton); leftButton = null; rightButton = null; } } layout(); repaint(); }
protected void oneTouchExpandableChanged() { if (splitPane.isOneTouchExpandable()) { leftButton = createLeftOneTouchButton(); rightButton = createRightOneTouchButton(); add(leftButton); add(rightButton); leftButton.addMouseListener(mouseHandler); rightButton.addMouseListener(mouseHandler); // Set it to 1. currentDividerLocation = 1; } else { if (leftButton != null && rightButton != null) { leftButton.removeMouseListener(mouseHandler); rightButton.removeMouseListener(mouseHandler); remove(leftButton); remove(rightButton); leftButton = null; rightButton = null; } } layout(); repaint(); }
6,529
protected void oneTouchExpandableChanged() { if (splitPane.isOneTouchExpandable()) { leftButton = createLeftOneTouchButton(); rightButton = createRightOneTouchButton(); add(leftButton); add(rightButton); leftButton.addMouseListener(mouseHandler); rightButton.addMouseListener(mouseHandler); // Set it to 1. currentDividerLocation = 1; } else { if (leftButton != null && rightButton != null) { leftButton.removeMouseListener(mouseHandler); rightButton.removeMouseListener(mouseHandler); remove(leftButton); remove(rightButton); leftButton = null; rightButton = null; } } layout(); repaint(); }
protected void oneTouchExpandableChanged() { if (splitPane.isOneTouchExpandable()) { leftButton = createLeftOneTouchButton(); rightButton = createRightOneTouchButton(); add(leftButton); add(rightButton); leftButton.addMouseListener(mouseHandler); rightButton.addMouseListener(mouseHandler); // Set it to 1. currentDividerLocation = 1; } else { if (leftButton != null && rightButton != null) { leftButton.removeMouseListener(mouseHandler); rightButton.removeMouseListener(mouseHandler); remove(leftButton); remove(rightButton); leftButton = null; rightButton = null; } } layout(); repaint(); }
6,530
public void paint(Graphics g) { Dimension dividerSize; super.paint(g); if (border != null) { dividerSize = getSize(); border.paintBorder(this, g, 0, 0, dividerSize.width, dividerSize.height); } if (splitPane.isOneTouchExpandable()) { ((BasicArrowButton) rightButton).paint(g); ((BasicArrowButton) leftButton).paint(g); } }
public void paint(Graphics g) { Dimension dividerSize; super.paint(g); if (border != null) { dividerSize = getSize(); border.paintBorder(this, g, 0, 0, dividerSize.width, dividerSize.height); } if (splitPane.isOneTouchExpandable()) { ((BasicArrowButton) rightButton).paint(g); ((BasicArrowButton) leftButton).paint(g); } }
6,531
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals(JSplitPane.ONE_TOUCH_EXPANDABLE_PROPERTY)) oneTouchExpandableChanged(); else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY)) { orientation = splitPane.getOrientation(); if (splitPane.isOneTouchExpandable()) { layout(); repaint(); } } else if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY)) dividerSize = splitPane.getDividerSize(); }
public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals(JSplitPane.ONE_TOUCH_EXPANDABLE_PROPERTY)) oneTouchExpandableChanged(); else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY)) { orientation = splitPane.getOrientation(); if (splitPane.isOneTouchExpandable()) { layout(); repaint(); } } else if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY)) dividerSize = splitPane.getDividerSize(); }
6,532