diff --git a/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core.jar b/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core.jar index 81e26742b..af289db5b 100644 Binary files a/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core.jar and b/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core.jar differ diff --git a/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core_3.1.1.jar b/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core_3.1.1.jar index 81e26742b..af289db5b 100644 Binary files a/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core_3.1.1.jar and b/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core_3.1.1.jar differ diff --git a/sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java b/sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java index ef0db1a75..ce6ad02ff 100644 --- a/sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java +++ b/sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java @@ -221,23 +221,24 @@ private void addApplication() { apps.add(getQualifiedClassName()); } - private void checkAddApplet(ITypeBinding binding) { + private boolean checkAddApplet(ITypeBinding binding) { if (Modifier.isAbstract(binding.getModifiers())) - return; + return false; ITypeBinding b = binding; while ((binding = binding.getSuperclass()) != null) { String name = binding.getQualifiedName(); if (!("javax.swing.JApplet".equals(name))) { if (name.startsWith("java.") || name.startsWith("javax")) - return; + return false; continue; } if (applets == null) applets = new ArrayList(); name = b.getQualifiedName(); applets.add(name); - break; + return true; } + return false; } public ArrayList getAppList(boolean isApplets) { @@ -265,6 +266,8 @@ private void setInnerGlobals(Java2ScriptVisitor parent, ASTNode node, String vis private ASTNode innerTypeNode; + private boolean isUserApplet; + public boolean visit(PackageDeclaration node) { setMapJavaDoc(node); String name = node.getName().toString(); @@ -613,16 +616,18 @@ public boolean visit(MethodDeclaration node) { if (key != null) methodDeclareNameStack.push(key); - boolean isStatic = isStatic(node); - boolean isNative = Modifier.isNative(node.getModifiers()); - + int mods = node.getModifiers(); + boolean isNative = Modifier.isNative(mods); + if (node.getBody() == null && !isNative) { // Abstract method return false; } + boolean isStatic = Modifier.isStatic(mods); boolean isConstructor = node.isConstructor(); - String name = getMethodNameOrArrayForDeclaration(node, mBinding, isConstructor); + boolean addUnqualified = isUserApplet && !isConstructor && !isStatic && Modifier.isPublic(mods); + String name = getMethodNameOrArrayForDeclaration(node, mBinding, isConstructor, addUnqualified); if (isConstructor && name.equals("'c$'") || mBinding.isVarargs() && mBinding.getParameterTypes().length == 1) haveDefaultConstructor = true; // in case we are not qualifying // names here @@ -1100,7 +1105,7 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List // check for a JApplet if (isTopLevel && !isEnum) { - checkAddApplet(binding); + isUserApplet = checkAddApplet(binding); } // add the anonymous wrapper if needed @@ -2050,10 +2055,10 @@ public boolean visit(Assignment node) { left.accept(this); switch (op) { case "|=": - buffer.append("||"); + buffer.append("|"); // surprise! | not || break; case "&=": - buffer.append("&&"); + buffer.append("&"); // & not && break; default: case "^=": @@ -3927,10 +3932,10 @@ private static void addGenericClassMethod(String classKey, String methodName, St * @return j2s-qualified name or an array of j2s-qualified names */ private String getMethodNameOrArrayForDeclaration(MethodDeclaration node, IMethodBinding mBinding, - boolean isConstructor) { + boolean isConstructor, boolean addUnqualified) { SimpleName nodeName = node.getName(); String methodName = (isConstructor ? "c$" : NameMapper.getJ2SName(nodeName)); - String name = getJ2SQualifiedName(methodName, null, mBinding, null, false); + String qname = getJ2SQualifiedName(methodName, null, mBinding, null, false); ITypeBinding methodClass = mBinding.getDeclaringClass(); List names = null; // System.err.println("checking methodList for " + nodeName.toString() + @@ -3950,16 +3955,19 @@ private String getMethodNameOrArrayForDeclaration(MethodDeclaration node, IMetho if (pname != null) names.add(pname); } + } else if (addUnqualified && !methodName.equals(qname)) { + names = new ArrayList(); + names.add(methodName); } if (names == null || names.size() == 0) - return "'" + name + "'"; - name = ",'" + name + "'"; + return "'" + qname + "'"; + qname = ",'" + qname + "'"; for (int i = names.size(); --i >= 0;) { String next = ",'" + names.get(i) + "'"; - if (name.indexOf(next) < 0) - name += next; + if (qname.indexOf(next) < 0) + qname += next; } - return "[" + name.substring(1) + "]"; + return "[" + qname.substring(1) + "]"; } /** diff --git a/sources/net.sf.j2s.java.core/SwingJS-site.zip b/sources/net.sf.j2s.java.core/SwingJS-site.zip new file mode 100644 index 000000000..53e1bd46c Binary files /dev/null and b/sources/net.sf.j2s.java.core/SwingJS-site.zip differ diff --git a/sources/net.sf.j2s.java.core/build_core_applet.xml b/sources/net.sf.j2s.java.core/build_core_applet.xml index 4441361c2..7cdb5b177 100644 --- a/sources/net.sf.j2s.java.core/build_core_applet.xml +++ b/sources/net.sf.j2s.java.core/build_core_applet.xml @@ -280,6 +280,22 @@ ${javaCoreAppletFiles} " /> + + creating swingjs2.js + + + + + copying srcjs files into site + + + + + TODO: Could delete demo html files? + + creating SwingJS-site.zip + + diff --git a/sources/net.sf.j2s.java.core/src/a2s/A2SEvent.java b/sources/net.sf.j2s.java.core/src/a2s/A2SEvent.java index 76a5d496b..90866bc97 100644 --- a/sources/net.sf.j2s.java.core/src/a2s/A2SEvent.java +++ b/sources/net.sf.j2s.java.core/src/a2s/A2SEvent.java @@ -133,6 +133,7 @@ static Event convertToOld(AWTEvent e) { getOldEventKey(ke), (ke.getModifiers() & ~InputEvent.BUTTON1_MASK)); + case MouseEvent.MOUSE_CLICKED: case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_RELEASED: case MouseEvent.MOUSE_MOVED: @@ -233,7 +234,10 @@ public static Component addListener(JComponent container, Component comp) { if (top == null) top = ((A2SContainer) ((JComponent) comp).getTopLevelAncestor()); if (top == null) - return comp; + if (comp instanceof A2SContainer) + top = (A2SContainer) comp; + else + return comp; A2SListener listener = top.getA2SListener(); if (comp instanceof AbstractButton) { if (!isListener(((AbstractButton) comp).getActionListeners(), listener)) diff --git a/sources/net.sf.j2s.java.core/src/a2s/Applet.java b/sources/net.sf.j2s.java.core/src/a2s/Applet.java index e7e75d8a4..30bc56246 100644 --- a/sources/net.sf.j2s.java.core/src/a2s/Applet.java +++ b/sources/net.sf.j2s.java.core/src/a2s/Applet.java @@ -55,8 +55,13 @@ public A2SListener getA2SListener() { // public void init() { // } + private boolean paintMeNotified; + protected void paintMe(Graphics g) { - System.out.println("paintMe has not been implemented!"); + if (!paintMeNotified) { + System.out.println("paintMe has not been implemented for " + this); + paintMeNotified = true; + } } diff --git a/sources/net.sf.j2s.java.core/src/a2s/Scrollbar.java b/sources/net.sf.j2s.java.core/src/a2s/Scrollbar.java index 3b29ba7d4..d46b36a79 100644 --- a/sources/net.sf.j2s.java.core/src/a2s/Scrollbar.java +++ b/sources/net.sf.j2s.java.core/src/a2s/Scrollbar.java @@ -2,18 +2,21 @@ import javax.swing.JScrollBar; -public class Scrollbar extends JScrollBar { +public class Scrollbar extends JScrollBar implements A2SContainer { public Scrollbar(int direction) { super(direction); + A2SEvent.addListener(null, this); } public Scrollbar() { super(); + A2SEvent.addListener(null, this); } public Scrollbar(int orientation, int value, int extent, int min, int max) { super(orientation, value, extent, min, max); + A2SEvent.addListener(null, this); } @Override @@ -36,6 +39,17 @@ public int getValue() { return super.getValue(); } + + // JCheckBox does not allow access to fireAdjustmentChanged. + // It really does not matter who holds the listener, actually. + A2SListener listener = null; + @Override + public A2SListener getA2SListener() { + if (listener == null) + listener = new A2SListener(); + return listener; + } + // public void addMouseListener(MouseListener c) { // //super.addMouseListener(c); // @@ -44,4 +58,5 @@ public int getValue() { // //super.addMouseMotionListener(c); // } + } diff --git a/sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java b/sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java index df8676a1c..bd6b6fda0 100644 --- a/sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java +++ b/sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java @@ -76,6 +76,8 @@ public static void ensurePropertyChangeListener(Component c, Component listener) * */ + public boolean isFramedApplet; + public String htmlName; protected int num; private static int incr; diff --git a/sources/net.sf.j2s.java.core/src/java/awt/MediaTracker.java b/sources/net.sf.j2s.java.core/src/java/awt/MediaTracker.java new file mode 100644 index 000000000..c4b1780eb --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/java/awt/MediaTracker.java @@ -0,0 +1,959 @@ +/* + * Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.awt; + +/** + * The MediaTracker class is a utility class to track + * the status of a number of media objects. Media objects could + * include audio clips as well as images, though currently only + * images are supported. + *

+ * To use a media tracker, create an instance of + * MediaTracker and call its addImage + * method for each image to be tracked. In addition, each image can + * be assigned a unique identifier. This identifier controls the + * priority order in which the images are fetched. It can also be used + * to identify unique subsets of the images that can be waited on + * independently. Images with a lower ID are loaded in preference to + * those with a higher ID number. + * + *

+ * + * Tracking an animated image + * might not always be useful + * due to the multi-part nature of animated image + * loading and painting, + * but it is supported. + * MediaTracker treats an animated image + * as completely loaded + * when the first frame is completely loaded. + * At that point, the MediaTracker + * signals any waiters + * that the image is completely loaded. + * If no ImageObservers are observing the image + * when the first frame has finished loading, + * the image might flush itself + * to conserve resources + * (see {@link Image#flush()}). + * + *

+ * Here is an example of using MediaTracker: + *

+ *


+ * import java.applet.Applet;
+ * import java.awt.Color;
+ * import java.awt.Image;
+ * import java.awt.Graphics;
+ * import java.awt.MediaTracker;
+ *
+ * public class ImageBlaster extends Applet implements Runnable {
+ *      MediaTracker tracker;
+ *      Image bg;
+ *      Image anim[] = new Image[5];
+ *      int index;
+ *      Thread animator;
+ *
+ *      // Get the images for the background (id == 0)
+ *      // and the animation frames (id == 1)
+ *      // and add them to the MediaTracker
+ *      public void init() {
+ *          tracker = new MediaTracker(this);
+ *          bg = getImage(getDocumentBase(),
+ *                  "images/background.gif");
+ *          tracker.addImage(bg, 0);
+ *          for (int i = 0; i < 5; i++) {
+ *              anim[i] = getImage(getDocumentBase(),
+ *                      "images/anim"+i+".gif");
+ *              tracker.addImage(anim[i], 1);
+ *          }
+ *      }
+ *
+ *      // Start the animation thread.
+ *      public void start() {
+ *          animator = new Thread(this);
+ *          animator.start();
+ *      }
+ *
+ *      // Stop the animation thread.
+ *      public void stop() {
+ *          animator = null;
+ *      }
+ *
+ *      // Run the animation thread.
+ *      // First wait for the background image to fully load
+ *      // and paint.  Then wait for all of the animation
+ *      // frames to finish loading. Finally, loop and
+ *      // increment the animation frame index.
+ *      public void run() {
+ *          try {
+ *              tracker.waitForID(0);
+ *              tracker.waitForID(1);
+ *          } catch (InterruptedException e) {
+ *              return;
+ *          }
+ *          Thread me = Thread.currentThread();
+ *          while (animator == me) {
+ *              try {
+ *                  Thread.sleep(100);
+ *              } catch (InterruptedException e) {
+ *                  break;
+ *              }
+ *              synchronized (this) {
+ *                  index++;
+ *                  if (index >= anim.length) {
+ *                      index = 0;
+ *                  }
+ *              }
+ *              repaint();
+ *          }
+ *      }
+ *
+ *      // The background image fills the frame so we
+ *      // don't need to clear the applet on repaints.
+ *      // Just call the paint method.
+ *      public void update(Graphics g) {
+ *          paint(g);
+ *      }
+ *
+ *      // Paint a large red rectangle if there are any errors
+ *      // loading the images.  Otherwise always paint the
+ *      // background so that it appears incrementally as it
+ *      // is loading.  Finally, only paint the current animation
+ *      // frame if all of the frames (id == 1) are done loading,
+ *      // so that we don't get partial animations.
+ *      public void paint(Graphics g) {
+ *          if ((tracker.statusAll(false) & MediaTracker.ERRORED) != 0) {
+ *              g.setColor(Color.red);
+ *              g.fillRect(0, 0, size().width, size().height);
+ *              return;
+ *          }
+ *          g.drawImage(bg, 0, 0, this);
+ *          if (tracker.statusID(1, false) == MediaTracker.COMPLETE) {
+ *              g.drawImage(anim[index], 10, 10, this);
+ *          }
+ *      }
+ * }
+ * 

+ * + * @author Jim Graham + * @since JDK1.0 + */ +public class MediaTracker implements java.io.Serializable { + + /** + * A given Component that will be + * tracked by a media tracker where the image will + * eventually be drawn. + * + * @serial + * @see #MediaTracker(Component) + */ + Component target; + /** + * The head of the list of Images that is being + * tracked by the MediaTracker. + * + * @serial + * @see #addImage(Image, int) + * @see #removeImage(Image) + */ +// MediaEntry head; + + /* + * JDK 1.1 serialVersionUID + */ + private static final long serialVersionUID = -483174189758638095L; + + /** + * Creates a media tracker to track images for a given component. + * @param comp the component on which the images + * will eventually be drawn + */ + public MediaTracker(Component comp) { + target = comp; + } + + /** + * Adds an image to the list of images being tracked by this media + * tracker. The image will eventually be rendered at its default + * (unscaled) size. + * @param image the image to be tracked + * @param id an identifier used to track this image + */ + public void addImage(Image image, int id) { + addImage(image, id, -1, -1); + } + + /** + * Adds a scaled image to the list of images being tracked + * by this media tracker. The image will eventually be + * rendered at the indicated width and height. + * + * @param image the image to be tracked + * @param id an identifier that can be used to track this image + * @param w the width at which the image is rendered + * @param h the height at which the image is rendered + */ + public synchronized void addImage(Image image, int id, int w, int h) { +// head = MediaEntry.insert(head, +// new ImageMediaEntry(this, image, id, w, h)); + } + + /** + * Flag indicating that media is currently being loaded. + * @see java.awt.MediaTracker#statusAll + * @see java.awt.MediaTracker#statusID + */ + public static final int LOADING = 1; + + /** + * Flag indicating that the downloading of media was aborted. + * @see java.awt.MediaTracker#statusAll + * @see java.awt.MediaTracker#statusID + */ + public static final int ABORTED = 2; + + /** + * Flag indicating that the downloading of media encountered + * an error. + * @see java.awt.MediaTracker#statusAll + * @see java.awt.MediaTracker#statusID + */ + public static final int ERRORED = 4; + + /** + * Flag indicating that the downloading of media was completed + * successfully. + * @see java.awt.MediaTracker#statusAll + * @see java.awt.MediaTracker#statusID + */ + public static final int COMPLETE = 8; + + static final int DONE = (ABORTED | ERRORED | COMPLETE); + + /** + * Checks to see if all images being tracked by this media tracker + * have finished loading. + *

+ * This method does not start loading the images if they are not + * already loading. + *

+ * If there is an error while loading or scaling an image, then that + * image is considered to have finished loading. Use the + * isErrorAny or isErrorID methods to + * check for errors. + * @return true if all images have finished loading, + * have been aborted, or have encountered + * an error; false otherwise + * @see java.awt.MediaTracker#checkAll(boolean) + * @see java.awt.MediaTracker#checkID + * @see java.awt.MediaTracker#isErrorAny + * @see java.awt.MediaTracker#isErrorID + */ + public boolean checkAll() { + return true; + // return checkAll(false, true); + } + + /** + * Checks to see if all images being tracked by this media tracker + * have finished loading. + *

+ * If the value of the load flag is true, + * then this method starts loading any images that are not yet + * being loaded. + *

+ * If there is an error while loading or scaling an image, that + * image is considered to have finished loading. Use the + * isErrorAny and isErrorID methods to + * check for errors. + * @param load if true, start loading any + * images that are not yet being loaded + * @return true if all images have finished loading, + * have been aborted, or have encountered + * an error; false otherwise + * @see java.awt.MediaTracker#checkID + * @see java.awt.MediaTracker#checkAll() + * @see java.awt.MediaTracker#isErrorAny() + * @see java.awt.MediaTracker#isErrorID(int) + */ + public boolean checkAll(boolean load) { + return true; +// return checkAll(load, true); + } + +// private synchronized boolean checkAll(boolean load, boolean verify) { +// MediaEntry cur = head; +// boolean done = true; +// while (cur != null) { +// if ((cur.getStatus(load, verify) & DONE) == 0) { +// done = false; +// } +// cur = cur.next; +// } +// return done; +// } + + /** + * Checks the error status of all of the images. + * @return true if any of the images tracked + * by this media tracker had an error during + * loading; false otherwise + * @see java.awt.MediaTracker#isErrorID + * @see java.awt.MediaTracker#getErrorsAny + */ + public synchronized boolean isErrorAny() { +// MediaEntry cur = head; +// while (cur != null) { +// if ((cur.getStatus(false, true) & ERRORED) != 0) { +// return true; +// } +// cur = cur.next; +// } + return false; + } + + /** + * Returns a list of all media that have encountered an error. + * @return an array of media objects tracked by this + * media tracker that have encountered + * an error, or null if + * there are none with errors + * @see java.awt.MediaTracker#isErrorAny + * @see java.awt.MediaTracker#getErrorsID + */ + public synchronized Object[] getErrorsAny() { +// MediaEntry cur = head; +// int numerrors = 0; +// while (cur != null) { +// if ((cur.getStatus(false, true) & ERRORED) != 0) { +// numerrors++; +// } +// cur = cur.next; +// } +// if (numerrors == 0) { +// return null; +// } +// Object errors[] = new Object[numerrors]; +// cur = head; +// numerrors = 0; +// while (cur != null) { +// if ((cur.getStatus(false, false) & ERRORED) != 0) { +// errors[numerrors++] = cur.getMedia(); +// } +// cur = cur.next; +// } +// return errors; + return null; + } + + /** + * Starts loading all images tracked by this media tracker. This + * method waits until all the images being tracked have finished + * loading. + *

+ * If there is an error while loading or scaling an image, then that + * image is considered to have finished loading. Use the + * isErrorAny or isErrorID methods to + * check for errors. + * @see java.awt.MediaTracker#waitForID(int) + * @see java.awt.MediaTracker#waitForAll(long) + * @see java.awt.MediaTracker#isErrorAny + * @see java.awt.MediaTracker#isErrorID + * @exception InterruptedException if any thread has + * interrupted this thread + */ + public void waitForAll() throws InterruptedException { + return; +// waitForAll(0); + } + + /** + * Starts loading all images tracked by this media tracker. This + * method waits until all the images being tracked have finished + * loading, or until the length of time specified in milliseconds + * by the ms argument has passed. + *

+ * If there is an error while loading or scaling an image, then + * that image is considered to have finished loading. Use the + * isErrorAny or isErrorID methods to + * check for errors. + * @param ms the number of milliseconds to wait + * for the loading to complete + * @return true if all images were successfully + * loaded; false otherwise + * @see java.awt.MediaTracker#waitForID(int) + * @see java.awt.MediaTracker#waitForAll(long) + * @see java.awt.MediaTracker#isErrorAny + * @see java.awt.MediaTracker#isErrorID + * @exception InterruptedException if any thread has + * interrupted this thread. + */ + public synchronized boolean waitForAll(long ms) + throws InterruptedException + { + return true; +// long end = System.currentTimeMillis() + ms; +// boolean first = true; +// while (true) { +// int status = statusAll(first, first); +// if ((status & LOADING) == 0) { +// return (status == COMPLETE); +// } +// first = false; +// long timeout; +// if (ms == 0) { +// timeout = 0; +// } else { +// timeout = end - System.currentTimeMillis(); +// if (timeout <= 0) { +// return false; +// } +// } +// wait(timeout); +// } + } + + /** + * Calculates and returns the bitwise inclusive OR of the + * status of all media that are tracked by this media tracker. + *

+ * Possible flags defined by the + * MediaTracker class are LOADING, + * ABORTED, ERRORED, and + * COMPLETE. An image that hasn't started + * loading has zero as its status. + *

+ * If the value of load is true, then + * this method starts loading any images that are not yet being loaded. + * + * @param load if true, start loading + * any images that are not yet being loaded + * @return the bitwise inclusive OR of the status of + * all of the media being tracked + * @see java.awt.MediaTracker#statusID(int, boolean) + * @see java.awt.MediaTracker#LOADING + * @see java.awt.MediaTracker#ABORTED + * @see java.awt.MediaTracker#ERRORED + * @see java.awt.MediaTracker#COMPLETE + */ + public int statusAll(boolean load) { + return COMPLETE; +// return statusAll(load, true); + } + +// private synchronized int statusAll(boolean load, boolean verify) { +// MediaEntry cur = head; +// int status = 0; +// while (cur != null) { +// status = status | cur.getStatus(load, verify); +// cur = cur.next; +// } +// return status; +// } + + /** + * Checks to see if all images tracked by this media tracker that + * are tagged with the specified identifier have finished loading. + *

+ * This method does not start loading the images if they are not + * already loading. + *

+ * If there is an error while loading or scaling an image, then that + * image is considered to have finished loading. Use the + * isErrorAny or isErrorID methods to + * check for errors. + * @param id the identifier of the images to check + * @return true if all images have finished loading, + * have been aborted, or have encountered + * an error; false otherwise + * @see java.awt.MediaTracker#checkID(int, boolean) + * @see java.awt.MediaTracker#checkAll() + * @see java.awt.MediaTracker#isErrorAny() + * @see java.awt.MediaTracker#isErrorID(int) + */ + public boolean checkID(int id) { + return true; +// return checkID(id, false, true); + } + + /** + * Checks to see if all images tracked by this media tracker that + * are tagged with the specified identifier have finished loading. + *

+ * If the value of the load flag is true, + * then this method starts loading any images that are not yet + * being loaded. + *

+ * If there is an error while loading or scaling an image, then that + * image is considered to have finished loading. Use the + * isErrorAny or isErrorID methods to + * check for errors. + * @param id the identifier of the images to check + * @param load if true, start loading any + * images that are not yet being loaded + * @return true if all images have finished loading, + * have been aborted, or have encountered + * an error; false otherwise + * @see java.awt.MediaTracker#checkID(int, boolean) + * @see java.awt.MediaTracker#checkAll() + * @see java.awt.MediaTracker#isErrorAny() + * @see java.awt.MediaTracker#isErrorID(int) + */ + public boolean checkID(int id, boolean load) { + return true; +// return checkID(id, load, true); + } + +// private synchronized boolean checkID(int id, boolean load, boolean verify) +// { +// MediaEntry cur = head; +// boolean done = true; +// while (cur != null) { +// if (cur.getID() == id +// && (cur.getStatus(load, verify) & DONE) == 0) +// { +// done = false; +// } +// cur = cur.next; +// } +// return done; +// } + + /** + * Checks the error status of all of the images tracked by this + * media tracker with the specified identifier. + * @param id the identifier of the images to check + * @return true if any of the images with the + * specified identifier had an error during + * loading; false otherwise + * @see java.awt.MediaTracker#isErrorAny + * @see java.awt.MediaTracker#getErrorsID + */ + public synchronized boolean isErrorID(int id) { +// MediaEntry cur = head; +// while (cur != null) { +// if (cur.getID() == id +// && (cur.getStatus(false, true) & ERRORED) != 0) +// { +// return true; +// } +// cur = cur.next; +// } + return false; + } + + /** + * Returns a list of media with the specified ID that + * have encountered an error. + * @param id the identifier of the images to check + * @return an array of media objects tracked by this media + * tracker with the specified identifier + * that have encountered an error, or + * null if there are none with errors + * @see java.awt.MediaTracker#isErrorID + * @see java.awt.MediaTracker#isErrorAny + * @see java.awt.MediaTracker#getErrorsAny + */ + public synchronized Object[] getErrorsID(int id) { +// MediaEntry cur = head; +// int numerrors = 0; +// while (cur != null) { +// if (cur.getID() == id +// && (cur.getStatus(false, true) & ERRORED) != 0) +// { +// numerrors++; +// } +// cur = cur.next; +// } +// if (numerrors == 0) { +// return null; +// } +// Object errors[] = new Object[numerrors]; +// cur = head; +// numerrors = 0; +// while (cur != null) { +// if (cur.getID() == id +// && (cur.getStatus(false, false) & ERRORED) != 0) +// { +// errors[numerrors++] = cur.getMedia(); +// } +// cur = cur.next; +// } +// return errors; + return null; + } + + /** + * Starts loading all images tracked by this media tracker with the + * specified identifier. This method waits until all the images with + * the specified identifier have finished loading. + *

+ * If there is an error while loading or scaling an image, then that + * image is considered to have finished loading. Use the + * isErrorAny and isErrorID methods to + * check for errors. + * @param id the identifier of the images to check + * @see java.awt.MediaTracker#waitForAll + * @see java.awt.MediaTracker#isErrorAny() + * @see java.awt.MediaTracker#isErrorID(int) + * @exception InterruptedException if any thread has + * interrupted this thread. + */ + public void waitForID(int id) throws InterruptedException { + return; +// waitForID(id, 0); + } + + /** + * Starts loading all images tracked by this media tracker with the + * specified identifier. This method waits until all the images with + * the specified identifier have finished loading, or until the + * length of time specified in milliseconds by the ms + * argument has passed. + *

+ * If there is an error while loading or scaling an image, then that + * image is considered to have finished loading. Use the + * statusID, isErrorID, and + * isErrorAny methods to check for errors. + * @param id the identifier of the images to check + * @param ms the length of time, in milliseconds, to wait + * for the loading to complete + * @see java.awt.MediaTracker#waitForAll + * @see java.awt.MediaTracker#waitForID(int) + * @see java.awt.MediaTracker#statusID + * @see java.awt.MediaTracker#isErrorAny() + * @see java.awt.MediaTracker#isErrorID(int) + * @exception InterruptedException if any thread has + * interrupted this thread. + */ + public synchronized boolean waitForID(int id, long ms) + throws InterruptedException + { + return true; // SwingJS all images are preloaded. +// long end = System.currentTimeMillis() + ms; +// boolean first = true; +// while (true) { +// int status = statusID(id, first, first); +// if ((status & LOADING) == 0) { +// return (status == COMPLETE); +// } +// first = false; +// long timeout; +// if (ms == 0) { +// timeout = 0; +// } else { +// timeout = end - System.currentTimeMillis(); +// if (timeout <= 0) { +// return false; +// } +// } +// wait(timeout); +// } + } + + /** + * Calculates and returns the bitwise inclusive OR of the + * status of all media with the specified identifier that are + * tracked by this media tracker. + *

+ * Possible flags defined by the + * MediaTracker class are LOADING, + * ABORTED, ERRORED, and + * COMPLETE. An image that hasn't started + * loading has zero as its status. + *

+ * If the value of load is true, then + * this method starts loading any images that are not yet being loaded. + * @param id the identifier of the images to check + * @param load if true, start loading + * any images that are not yet being loaded + * @return the bitwise inclusive OR of the status of + * all of the media with the specified + * identifier that are being tracked + * @see java.awt.MediaTracker#statusAll(boolean) + * @see java.awt.MediaTracker#LOADING + * @see java.awt.MediaTracker#ABORTED + * @see java.awt.MediaTracker#ERRORED + * @see java.awt.MediaTracker#COMPLETE + */ + public int statusID(int id, boolean load) { + return COMPLETE; +// return statusID(id, load, true); + } + +// private synchronized int statusID(int id, boolean load, boolean verify) { +// MediaEntry cur = head; +// int status = 0; +// while (cur != null) { +// if (cur.getID() == id) { +// status = status | cur.getStatus(load, verify); +// } +// cur = cur.next; +// } +// return status; +// } + + /** + * Removes the specified image from this media tracker. + * All instances of the specified image are removed, + * regardless of scale or ID. + * @param image the image to be removed + * @see java.awt.MediaTracker#removeImage(java.awt.Image, int) + * @see java.awt.MediaTracker#removeImage(java.awt.Image, int, int, int) + * @since JDK1.1 + */ + public synchronized void removeImage(Image image) { +// MediaEntry cur = head; +// MediaEntry prev = null; +// while (cur != null) { +// MediaEntry next = cur.next; +// if (cur.getMedia() == image) { +// if (prev == null) { +// head = next; +// } else { +// prev.next = next; +// } +// cur.cancel(); +// } else { +// prev = cur; +// } +// cur = next; +// } +// notifyAll(); // Notify in case remaining images are "done". + } + + /** + * Removes the specified image from the specified tracking + * ID of this media tracker. + * All instances of Image being tracked + * under the specified ID are removed regardless of scale. + * @param image the image to be removed + * @param id the tracking ID frrom which to remove the image + * @see java.awt.MediaTracker#removeImage(java.awt.Image) + * @see java.awt.MediaTracker#removeImage(java.awt.Image, int, int, int) + * @since JDK1.1 + */ + public synchronized void removeImage(Image image, int id) { +// MediaEntry cur = head; +// MediaEntry prev = null; +// while (cur != null) { +// MediaEntry next = cur.next; +// if (cur.getID() == id && cur.getMedia() == image) { +// if (prev == null) { +// head = next; +// } else { +// prev.next = next; +// } +// cur.cancel(); +// } else { +// prev = cur; +// } +// cur = next; +// } +// notifyAll(); // Notify in case remaining images are "done". + } + + /** + * Removes the specified image with the specified + * width, height, and ID from this media tracker. + * Only the specified instance (with any duplicates) is removed. + * @param image the image to be removed + * @param id the tracking ID from which to remove the image + * @param width the width to remove (-1 for unscaled) + * @param height the height to remove (-1 for unscaled) + * @see java.awt.MediaTracker#removeImage(java.awt.Image) + * @see java.awt.MediaTracker#removeImage(java.awt.Image, int) + * @since JDK1.1 + */ + public synchronized void removeImage(Image image, int id, + int width, int height) { +// MediaEntry cur = head; +// MediaEntry prev = null; +// while (cur != null) { +// MediaEntry next = cur.next; +// if (cur.getID() == id && cur instanceof ImageMediaEntry +// && ((ImageMediaEntry) cur).matches(image, width, height)) +// { +// if (prev == null) { +// head = next; +// } else { +// prev.next = next; +// } +// cur.cancel(); +// } else { +// prev = cur; +// } +// cur = next; +// } +// notifyAll(); // Notify in case remaining images are "done". + } + + synchronized void setDone() { + return; +// notifyAll(); + } +} + +//abstract class MediaEntry { +// MediaTracker tracker; +// int ID; +// MediaEntry next; +// +// int status; +// boolean cancelled; +// +// MediaEntry(MediaTracker mt, int id) { +// tracker = mt; +// ID = id; +// } +// +// abstract Object getMedia(); +// +// static MediaEntry insert(MediaEntry head, MediaEntry me) { +// MediaEntry cur = head; +// MediaEntry prev = null; +// while (cur != null) { +// if (cur.ID > me.ID) { +// break; +// } +// prev = cur; +// cur = cur.next; +// } +// me.next = cur; +// if (prev == null) { +// head = me; +// } else { +// prev.next = me; +// } +// return head; +// } +// +// int getID() { +// return ID; +// } +// +// abstract void startLoad(); +// +// void cancel() { +// cancelled = true; +// } +// +// static final int LOADING = MediaTracker.LOADING; +// static final int ABORTED = MediaTracker.ABORTED; +// static final int ERRORED = MediaTracker.ERRORED; +// static final int COMPLETE = MediaTracker.COMPLETE; +// +// static final int LOADSTARTED = (LOADING | ERRORED | COMPLETE); +// static final int DONE = (ABORTED | ERRORED | COMPLETE); +// +// synchronized int getStatus(boolean doLoad, boolean doVerify) { +// return COMPLETE; +//// if (doLoad && ((status & LOADSTARTED) == 0)) { +//// status = (status & ~ABORTED) | LOADING; +//// startLoad(); +//// } +//// return status; +// } +// +// void setStatus(int flag) { +// synchronized (this) { +// status = flag; +// } +// tracker.setDone(); +// } +//} + +//class ImageMediaEntry extends MediaEntry implements ImageObserver, +//java.io.Serializable { +// Image image; +// int width; +// int height; +// +// /* +// * JDK 1.1 serialVersionUID +// */ +// private static final long serialVersionUID = 4739377000350280650L; +// +// ImageMediaEntry(MediaTracker mt, Image img, int c, int w, int h) { +// super(mt, c); +// image = img; +// width = w; +// height = h; +// } +// +// boolean matches(Image img, int w, int h) { +// return (image == img && width == w && height == h); +// } +// +// Object getMedia() { +// return image; +// } +// +// synchronized int getStatus(boolean doLoad, boolean doVerify) { +// if (doVerify) { +// int flags = tracker.target.checkImage(image, width, height, null); +// int s = parseflags(flags); +// if (s == 0) { +// if ((status & (ERRORED | COMPLETE)) != 0) { +// setStatus(ABORTED); +// } +// } else if (s != status) { +// setStatus(s); +// } +// } +// return super.getStatus(doLoad, doVerify); +// } +// +// void startLoad() { +//// if (tracker.target.prepareImage(image, width, height, this)) { +// setStatus(COMPLETE); +//// } +// } +// +// int parseflags(int infoflags) { +// if ((infoflags & ERROR) != 0) { +// return ERRORED; +// } else if ((infoflags & ABORT) != 0) { +// return ABORTED; +// } else if ((infoflags & (ALLBITS | FRAMEBITS)) != 0) { +// return COMPLETE; +// } +// return 0; +// } +// +// public boolean imageUpdate(Image img, int infoflags, +// int x, int y, int w, int h) { +// if (cancelled) { +// return false; +// } +// int s = parseflags(infoflags); +// if (s != 0 && s != status) { +// setStatus(s); +// } +// return ((status & LOADING) != 0); +// } +//} diff --git a/sources/net.sf.j2s.java.core/src/java/awt/SystemColor.java b/sources/net.sf.j2s.java.core/src/java/awt/SystemColor.java new file mode 100644 index 000000000..fb51d7196 --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/java/awt/SystemColor.java @@ -0,0 +1,543 @@ +/* + * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ +package java.awt; + +import java.io.ObjectStreamException; + +/** + * A class to encapsulate symbolic colors representing the color of + * native GUI objects on a system. For systems which support the dynamic + * update of the system colors (when the user changes the colors) + * the actual RGB values of these symbolic colors will also change + * dynamically. In order to compare the "current" RGB value of a + * SystemColor object with a non-symbolic Color object, + * getRGB should be used rather than equals. + *

+ * Note that the way in which these system colors are applied to GUI objects + * may vary slightly from platform to platform since GUI objects may be + * rendered differently on each platform. + *

+ * System color values may also be available through the getDesktopProperty + * method on java.awt.Toolkit. + * + * @see Toolkit#getDesktopProperty + * + * @author Carl Quinn + * @author Amy Fowler + */ +public final class SystemColor extends Color implements java.io.Serializable { + + /** + * The array index for the + * {@link #desktop} system color. + * @see SystemColor#desktop + */ + public final static int DESKTOP = 0; + + /** + * The array index for the + * {@link #activeCaption} system color. + * @see SystemColor#activeCaption + */ + public final static int ACTIVE_CAPTION = 1; + + /** + * The array index for the + * {@link #activeCaptionText} system color. + * @see SystemColor#activeCaptionText + */ + public final static int ACTIVE_CAPTION_TEXT = 2; + + /** + * The array index for the + * {@link #activeCaptionBorder} system color. + * @see SystemColor#activeCaptionBorder + */ + public final static int ACTIVE_CAPTION_BORDER = 3; + + /** + * The array index for the + * {@link #inactiveCaption} system color. + * @see SystemColor#inactiveCaption + */ + public final static int INACTIVE_CAPTION = 4; + + /** + * The array index for the + * {@link #inactiveCaptionText} system color. + * @see SystemColor#inactiveCaptionText + */ + public final static int INACTIVE_CAPTION_TEXT = 5; + + /** + * The array index for the + * {@link #inactiveCaptionBorder} system color. + * @see SystemColor#inactiveCaptionBorder + */ + public final static int INACTIVE_CAPTION_BORDER = 6; + + /** + * The array index for the + * {@link #window} system color. + * @see SystemColor#window + */ + public final static int WINDOW = 7; + + /** + * The array index for the + * {@link #windowBorder} system color. + * @see SystemColor#windowBorder + */ + public final static int WINDOW_BORDER = 8; + + /** + * The array index for the + * {@link #windowText} system color. + * @see SystemColor#windowText + */ + public final static int WINDOW_TEXT = 9; + + /** + * The array index for the + * {@link #menu} system color. + * @see SystemColor#menu + */ + public final static int MENU = 10; + + /** + * The array index for the + * {@link #menuText} system color. + * @see SystemColor#menuText + */ + public final static int MENU_TEXT = 11; + + /** + * The array index for the + * {@link #text} system color. + * @see SystemColor#text + */ + public final static int TEXT = 12; + + /** + * The array index for the + * {@link #textText} system color. + * @see SystemColor#textText + */ + public final static int TEXT_TEXT = 13; + + /** + * The array index for the + * {@link #textHighlight} system color. + * @see SystemColor#textHighlight + */ + public final static int TEXT_HIGHLIGHT = 14; + + /** + * The array index for the + * {@link #textHighlightText} system color. + * @see SystemColor#textHighlightText + */ + public final static int TEXT_HIGHLIGHT_TEXT = 15; + + /** + * The array index for the + * {@link #textInactiveText} system color. + * @see SystemColor#textInactiveText + */ + public final static int TEXT_INACTIVE_TEXT = 16; + + /** + * The array index for the + * {@link #control} system color. + * @see SystemColor#control + */ + public final static int CONTROL = 17; + + /** + * The array index for the + * {@link #controlText} system color. + * @see SystemColor#controlText + */ + public final static int CONTROL_TEXT = 18; + + /** + * The array index for the + * {@link #controlHighlight} system color. + * @see SystemColor#controlHighlight + */ + public final static int CONTROL_HIGHLIGHT = 19; + + /** + * The array index for the + * {@link #controlLtHighlight} system color. + * @see SystemColor#controlLtHighlight + */ + public final static int CONTROL_LT_HIGHLIGHT = 20; + + /** + * The array index for the + * {@link #controlShadow} system color. + * @see SystemColor#controlShadow + */ + public final static int CONTROL_SHADOW = 21; + + /** + * The array index for the + * {@link #controlDkShadow} system color. + * @see SystemColor#controlDkShadow + */ + public final static int CONTROL_DK_SHADOW = 22; + + /** + * The array index for the + * {@link #scrollbar} system color. + * @see SystemColor#scrollbar + */ + public final static int SCROLLBAR = 23; + + /** + * The array index for the + * {@link #info} system color. + * @see SystemColor#info + */ + public final static int INFO = 24; + + /** + * The array index for the + * {@link #infoText} system color. + * @see SystemColor#infoText + */ + public final static int INFO_TEXT = 25; + + /** + * The number of system colors in the array. + */ + public final static int NUM_COLORS = 26; + + /******************************************************************************************/ + + /* + * System colors with default initial values, overwritten by toolkit if + * system values differ and are available. + * Should put array initialization above first field that is using + * SystemColor constructor to initialize. + */ + private static int[] systemColors = { + 0xFF005C5C, // desktop = new Color(0,92,92); + 0xFF000080, // activeCaption = new Color(0,0,128); + 0xFFFFFFFF, // activeCaptionText = Color.white; + 0xFFC0C0C0, // activeCaptionBorder = Color.lightGray; + 0xFF808080, // inactiveCaption = Color.gray; + 0xFFC0C0C0, // inactiveCaptionText = Color.lightGray; + 0xFFC0C0C0, // inactiveCaptionBorder = Color.lightGray; + 0xFFFFFFFF, // window = Color.white; + 0xFF000000, // windowBorder = Color.black; + 0xFF000000, // windowText = Color.black; + 0xFFC0C0C0, // menu = Color.lightGray; + 0xFF000000, // menuText = Color.black; + 0xFFC0C0C0, // text = Color.lightGray; + 0xFF000000, // textText = Color.black; + 0xFF000080, // textHighlight = new Color(0,0,128); + 0xFFFFFFFF, // textHighlightText = Color.white; + 0xFF808080, // textInactiveText = Color.gray; + 0xFFC0C0C0, // control = Color.lightGray; + 0xFF000000, // controlText = Color.black; + 0xFFFFFFFF, // controlHighlight = Color.white; + 0xFFE0E0E0, // controlLtHighlight = new Color(224,224,224); + 0xFF808080, // controlShadow = Color.gray; + 0xFF000000, // controlDkShadow = Color.black; + 0xFFE0E0E0, // scrollbar = new Color(224,224,224); + 0xFFE0E000, // info = new Color(224,224,0); + 0xFF000000, // infoText = Color.black; + }; + + /** + * The color rendered for the background of the desktop. + */ + public final static SystemColor desktop = new SystemColor((byte)DESKTOP); + + /** + * The color rendered for the window-title background of the currently active window. + */ + public final static SystemColor activeCaption = new SystemColor((byte)ACTIVE_CAPTION); + + /** + * The color rendered for the window-title text of the currently active window. + */ + public final static SystemColor activeCaptionText = new SystemColor((byte)ACTIVE_CAPTION_TEXT); + + /** + * The color rendered for the border around the currently active window. + */ + public final static SystemColor activeCaptionBorder = new SystemColor((byte)ACTIVE_CAPTION_BORDER); + + /** + * The color rendered for the window-title background of inactive windows. + */ + public final static SystemColor inactiveCaption = new SystemColor((byte)INACTIVE_CAPTION); + + /** + * The color rendered for the window-title text of inactive windows. + */ + public final static SystemColor inactiveCaptionText = new SystemColor((byte)INACTIVE_CAPTION_TEXT); + + /** + * The color rendered for the border around inactive windows. + */ + public final static SystemColor inactiveCaptionBorder = new SystemColor((byte)INACTIVE_CAPTION_BORDER); + + /** + * The color rendered for the background of interior regions inside windows. + */ + public final static SystemColor window = new SystemColor((byte)WINDOW); + + /** + * The color rendered for the border around interior regions inside windows. + */ + public final static SystemColor windowBorder = new SystemColor((byte)WINDOW_BORDER); + + /** + * The color rendered for text of interior regions inside windows. + */ + public final static SystemColor windowText = new SystemColor((byte)WINDOW_TEXT); + + /** + * The color rendered for the background of menus. + */ + public final static SystemColor menu = new SystemColor((byte)MENU); + + /** + * The color rendered for the text of menus. + */ + public final static SystemColor menuText = new SystemColor((byte)MENU_TEXT); + + /** + * The color rendered for the background of text control objects, such as + * textfields and comboboxes. + */ + public final static SystemColor text = new SystemColor((byte)TEXT); + + /** + * The color rendered for the text of text control objects, such as textfields + * and comboboxes. + */ + public final static SystemColor textText = new SystemColor((byte)TEXT_TEXT); + + /** + * The color rendered for the background of selected items, such as in menus, + * comboboxes, and text. + */ + public final static SystemColor textHighlight = new SystemColor((byte)TEXT_HIGHLIGHT); + + /** + * The color rendered for the text of selected items, such as in menus, comboboxes, + * and text. + */ + public final static SystemColor textHighlightText = new SystemColor((byte)TEXT_HIGHLIGHT_TEXT); + + /** + * The color rendered for the text of inactive items, such as in menus. + */ + public final static SystemColor textInactiveText = new SystemColor((byte)TEXT_INACTIVE_TEXT); + + /** + * The color rendered for the background of control panels and control objects, + * such as pushbuttons. + */ + public final static SystemColor control = new SystemColor((byte)CONTROL); + + /** + * The color rendered for the text of control panels and control objects, + * such as pushbuttons. + */ + public final static SystemColor controlText = new SystemColor((byte)CONTROL_TEXT); + + /** + * The color rendered for light areas of 3D control objects, such as pushbuttons. + * This color is typically derived from the control background color + * to provide a 3D effect. + */ + public final static SystemColor controlHighlight = new SystemColor((byte)CONTROL_HIGHLIGHT); + + /** + * The color rendered for highlight areas of 3D control objects, such as pushbuttons. + * This color is typically derived from the control background color + * to provide a 3D effect. + */ + public final static SystemColor controlLtHighlight = new SystemColor((byte)CONTROL_LT_HIGHLIGHT); + + /** + * The color rendered for shadow areas of 3D control objects, such as pushbuttons. + * This color is typically derived from the control background color + * to provide a 3D effect. + */ + public final static SystemColor controlShadow = new SystemColor((byte)CONTROL_SHADOW); + + /** + * The color rendered for dark shadow areas on 3D control objects, such as pushbuttons. + * This color is typically derived from the control background color + * to provide a 3D effect. + */ + public final static SystemColor controlDkShadow = new SystemColor((byte)CONTROL_DK_SHADOW); + + /** + * The color rendered for the background of scrollbars. + */ + public final static SystemColor scrollbar = new SystemColor((byte)SCROLLBAR); + + /** + * The color rendered for the background of tooltips or spot help. + */ + public final static SystemColor info = new SystemColor((byte)INFO); + + /** + * The color rendered for the text of tooltips or spot help. + */ + public final static SystemColor infoText = new SystemColor((byte)INFO_TEXT); + + /* + * JDK 1.1 serialVersionUID. + */ + private static final long serialVersionUID = 4503142729533789064L; + + /* + * An index into either array of SystemColor objects or values. + */ + private transient int index; + + private static SystemColor systemColorObjects [] = { + SystemColor.desktop, + SystemColor.activeCaption, + SystemColor.activeCaptionText, + SystemColor.activeCaptionBorder, + SystemColor.inactiveCaption, + SystemColor.inactiveCaptionText, + SystemColor.inactiveCaptionBorder, + SystemColor.window, + SystemColor.windowBorder, + SystemColor.windowText, + SystemColor.menu, + SystemColor.menuText, + SystemColor.text, + SystemColor.textText, + SystemColor.textHighlight, + SystemColor.textHighlightText, + SystemColor.textInactiveText, + SystemColor.control, + SystemColor.controlText, + SystemColor.controlHighlight, + SystemColor.controlLtHighlight, + SystemColor.controlShadow, + SystemColor.controlDkShadow, + SystemColor.scrollbar, + SystemColor.info, + SystemColor.infoText + }; + + static { + updateSystemColors(); + } + + /** + * Called from & toolkit to update the above systemColors cache. + */ + private static void updateSystemColors() { + if (!GraphicsEnvironment.isHeadless()) { + Toolkit.getDefaultToolkit().loadSystemColors(systemColors); + } + for (int i = 0; i < systemColors.length; i++) { + systemColorObjects[i].value = systemColors[i]; + } + } + + /** + * Creates a symbolic color that represents an indexed entry into system + * color cache. Used by above static system colors. + */ + private SystemColor(byte index) { + super(systemColors[index]); + this.index = index; + } + + /** + * Returns a string representation of this Color's values. + * This method is intended to be used only for debugging purposes, + * and the content and format of the returned string may vary between + * implementations. + * The returned string may be empty but may not be null. + * + * @return a string representation of this Color + */ + public String toString() { + return getClass().getName() + "[i=" + (index) + "]"; + } + + /** + * The design of the {@code SystemColor} class assumes that + * the {@code SystemColor} object instances stored in the + * static final fields above are the only instances that can + * be used by developers. + * This method helps maintain those limits on instantiation + * by using the index stored in the value field of the + * serialized form of the object to replace the serialized + * object with the equivalent static object constant field + * of {@code SystemColor}. + * See the {@link #writeReplace} method for more information + * on the serialized form of these objects. + * @return one of the {@code SystemColor} static object + * fields that refers to the same system color. + */ + private Object readResolve() { + // The instances of SystemColor are tightly controlled and + // only the canonical instances appearing above as static + // constants are allowed. The serial form of SystemColor + // objects stores the color index as the value. Here we + // map that index back into the canonical instance. + return systemColorObjects[value]; + } + + /** + * Returns a specialized version of the {@code SystemColor} + * object for writing to the serialized stream. + * @serialData + * The value field of a serialized {@code SystemColor} object + * contains the array index of the system color instead of the + * rgb data for the system color. + * This index is used by the {@link #readResolve} method to + * resolve the deserialized objects back to the original + * static constant versions to ensure unique instances of + * each {@code SystemColor} object. + * @return a proxy {@code SystemColor} object with its value + * replaced by the corresponding system color index. + */ + private Object writeReplace() throws ObjectStreamException + { + // we put an array index in the SystemColor.value while serialize + // to keep compatibility. + SystemColor color = new SystemColor((byte)index); + color.value = index; + return color; + } +} diff --git a/sources/net.sf.j2s.java.core/src/java/io/BufferedInputStream.java b/sources/net.sf.j2s.java.core/src/java/io/BufferedInputStream.java index ff5b8edba..8100b7f51 100644 --- a/sources/net.sf.j2s.java.core/src/java/io/BufferedInputStream.java +++ b/sources/net.sf.j2s.java.core/src/java/io/BufferedInputStream.java @@ -375,12 +375,12 @@ public synchronized long skip(long amount) throws IOException { return read + in.skip(amount - read); } - /** - * BH: Addeed to allow full reset of a bundled stream - */ - @Override - public void resetStream() { - markpos = pos = count = 0; - in.resetStream(); - } +// /** +// * BH: Addeed to allow full reset of a bundled stream +// */ +// @Override +// public void resetStream() { +// markpos = pos = count = 0; +// in.resetStream(); +// } } diff --git a/sources/net.sf.j2s.java.core/src/java/io/ByteArrayInputStream.java b/sources/net.sf.j2s.java.core/src/java/io/ByteArrayInputStream.java index 025771118..f317be726 100644 --- a/sources/net.sf.j2s.java.core/src/java/io/ByteArrayInputStream.java +++ b/sources/net.sf.j2s.java.core/src/java/io/ByteArrayInputStream.java @@ -213,13 +213,13 @@ public synchronized long skip(long n) { return pos - temp; } - /** - * BH: Allows resetting of the stream when a new InputStreamReader is invoked - */ - @Override - public void resetStream() { - mark = pos = 0; - } - +// /** +// * BH: Allows resetting of the stream when a new InputStreamReader is invoked +// */ +// @Override +// public void resetStream() { +// mark = pos = 0; +// } +// } diff --git a/sources/net.sf.j2s.java.core/src/java/io/FilterInputStream.java b/sources/net.sf.j2s.java.core/src/java/io/FilterInputStream.java index 0307cab54..40bb7be2a 100644 --- a/sources/net.sf.j2s.java.core/src/java/io/FilterInputStream.java +++ b/sources/net.sf.j2s.java.core/src/java/io/FilterInputStream.java @@ -1,198 +1,208 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.io; - - -/** - * FilteredInputStream is a class which takes an input stream and - * filters the input in some way. The filtered view may be a buffered - * view or one which uncompresses data before returning bytes read. - * FilterInputStreams are meant for byte streams. - * - * @see FilterOutputStream - */ -public class FilterInputStream extends InputStream { - - /** - * The target InputStream which is being filtered. - */ - protected InputStream in; - - /** - * Constructs a new FilterInputStream on the InputStream in. - * All reads are now filtered through this stream. - * - * @param in - * The non-null InputStream to filter reads on. - */ - protected FilterInputStream(InputStream in) { - super(); - this.in = in; - } - - /** - * Answers a int representing the number of bytes that are available before - * this FilterInputStream will block. This method returns the number of - * bytes available in the target stream. - * - * @return the number of bytes available before blocking. - * - * @throws IOException - * If an error occurs in this stream. - */ - @Override - public int available() throws IOException { - return in.available(); - } - - /** - * Close this FilterInputStream. This implementation closes the target - * stream. - * - * @throws IOException - * If an error occurs attempting to close this stream. - */ - @Override - public void close() throws IOException { - in.close(); - } - - /** - * Set a Mark position in this FilterInputStream. The parameter - * readLimit indicates how many bytes can be read before a - * mark is invalidated. Sending reset() will reposition the Stream back to - * the marked position provided readLimit has not been - * surpassed. - *

- * This implementation sets a mark in the target stream. - * - * @param readlimit - * the number of bytes to be able to read before invalidating the - * mark. - */ - @Override - public synchronized void mark(int readlimit) { - in.mark(readlimit); - } - - /** - * Answers a boolean indicating whether or not this FilterInputStream - * supports mark() and reset(). This implementation answers whether or not - * the target stream supports marking. - * - * @return true if mark() and reset() are supported, - * false otherwise. - */ - @Override - public boolean markSupported() { - return in.markSupported(); - } - - /** - * Reads a single byte from this FilterInputStream and returns the result as - * an int. The low-order byte is returned or -1 of the end of stream was - * encountered. This implementation returns a byte from the target stream. - * - * @return the byte read or -1 if end of stream. - * - * @throws IOException - * If the stream is already closed or another IOException - * occurs. - */ - @Override - public int read() throws IOException { - return in.read(); - } - - /** - * Reads bytes from this FilterInputStream and stores them in byte array - * buffer. Answer the number of bytes actually read or -1 if - * no bytes were read and end of stream was encountered. This implementation - * reads bytes from the target stream. - * - * @param buffer - * the byte array in which to store the read bytes. - * @return the number of bytes actually read or -1 if end of stream. - * - * @throws IOException - * If the stream is already closed or another IOException - * occurs. - */ - @Override - public int read(byte[] buffer) throws IOException { - return read(buffer, 0, buffer.length); - } - - /** - * Reads at most count bytes from this FilterInputStream and - * stores them in byte array buffer starting at - * offset. Answer the number of bytes actually read or -1 if - * no bytes were read and end of stream was encountered. This implementation - * reads bytes from the target stream. - * - * @param buffer - * the byte array in which to store the read bytes. - * @param offset - * the offset in buffer to store the read bytes. - * @param count - * the maximum number of bytes to store in buffer. - * @return the number of bytes actually read or -1 if end of stream. - * - * @throws IOException - * If the stream is already closed or another IOException - * occurs. - */ - @Override - public int read(byte[] buffer, int offset, int count) throws IOException { - return in.read(buffer, offset, count); - } - - /** - * Reset this FilterInputStream to the last marked location. If the - * readlimit has been passed or no mark has - * been set, throw IOException. This implementation resets the target - * stream. - * - * @throws IOException - * If the stream is already closed or another IOException - * occurs. - */ - @Override - public synchronized void reset() throws IOException { - in.reset(); - } - - /** - * Skips count number of bytes in this InputStream. - * Subsequent read()'s will not return these bytes unless - * reset() is used. This implementation skips - * count number of bytes in the target stream. - * - * @param count - * the number of bytes to skip. - * @return the number of bytes actually skipped. - * - * @throws IOException - * If the stream is already closed or another IOException - * occurs. - */ - @Override - public long skip(long count) throws IOException { - return in.skip(count); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.io; + + +/** + * FilteredInputStream is a class which takes an input stream and + * filters the input in some way. The filtered view may be a buffered + * view or one which uncompresses data before returning bytes read. + * FilterInputStreams are meant for byte streams. + * + * @see FilterOutputStream + */ +public class FilterInputStream extends InputStream { + + /** + * The target InputStream which is being filtered. + */ + protected InputStream in; + + /** + * Constructs a new FilterInputStream on the InputStream in. + * All reads are now filtered through this stream. + * + * @param in + * The non-null InputStream to filter reads on. + */ + protected FilterInputStream(InputStream in) { + super(); + this.in = in; + } + + /** + * Answers a int representing the number of bytes that are available before + * this FilterInputStream will block. This method returns the number of + * bytes available in the target stream. + * + * @return the number of bytes available before blocking. + * + * @throws IOException + * If an error occurs in this stream. + */ + @Override + public int available() throws IOException { + return in.available(); + } + + /** + * Close this FilterInputStream. This implementation closes the target + * stream. + * + * @throws IOException + * If an error occurs attempting to close this stream. + */ + @Override + public void close() throws IOException { + in.close(); + } + + /** + * Set a Mark position in this FilterInputStream. The parameter + * readLimit indicates how many bytes can be read before a + * mark is invalidated. Sending reset() will reposition the Stream back to + * the marked position provided readLimit has not been + * surpassed. + *

+ * This implementation sets a mark in the target stream. + * + * @param readlimit + * the number of bytes to be able to read before invalidating the + * mark. + */ + @Override + public synchronized void mark(int readlimit) { + in.mark(readlimit); + } + + /** + * Answers a boolean indicating whether or not this FilterInputStream + * supports mark() and reset(). This implementation answers whether or not + * the target stream supports marking. + * + * @return true if mark() and reset() are supported, + * false otherwise. + */ + @Override + public boolean markSupported() { + return in.markSupported(); + } + + /** + * Reads a single byte from this FilterInputStream and returns the result as + * an int. The low-order byte is returned or -1 of the end of stream was + * encountered. This implementation returns a byte from the target stream. + * + * @return the byte read or -1 if end of stream. + * + * @throws IOException + * If the stream is already closed or another IOException + * occurs. + */ + @Override + public int read() throws IOException { + return in.read(); + } + + /** + * Reads bytes from this FilterInputStream and stores them in byte array + * buffer. Answer the number of bytes actually read or -1 if + * no bytes were read and end of stream was encountered. This implementation + * reads bytes from the target stream. + * + * @param buffer + * the byte array in which to store the read bytes. + * @return the number of bytes actually read or -1 if end of stream. + * + * @throws IOException + * If the stream is already closed or another IOException + * occurs. + */ + @Override + public int read(byte[] buffer) throws IOException { + return read(buffer, 0, buffer.length); + } + + /** + * Reads at most count bytes from this FilterInputStream and + * stores them in byte array buffer starting at + * offset. Answer the number of bytes actually read or -1 if + * no bytes were read and end of stream was encountered. This implementation + * reads bytes from the target stream. + * + * @param buffer + * the byte array in which to store the read bytes. + * @param offset + * the offset in buffer to store the read bytes. + * @param count + * the maximum number of bytes to store in buffer. + * @return the number of bytes actually read or -1 if end of stream. + * + * @throws IOException + * If the stream is already closed or another IOException + * occurs. + */ + @Override + public int read(byte[] buffer, int offset, int count) throws IOException { + return in.read(buffer, offset, count); + } + + /** + * Reset this FilterInputStream to the last marked location. If the + * readlimit has been passed or no mark has + * been set, throw IOException. This implementation resets the target + * stream. + * + * @throws IOException + * If the stream is already closed or another IOException + * occurs. + */ + @Override + public synchronized void reset() throws IOException { + in.reset(); + } + +// /** +// * BH: Added to allow full reset of a bundled stream +// */ +// @Override +// public void resetStream() { +// in.resetStream(); +// } +// + + + /** + * Skips count number of bytes in this InputStream. + * Subsequent read()'s will not return these bytes unless + * reset() is used. This implementation skips + * count number of bytes in the target stream. + * + * @param count + * the number of bytes to skip. + * @return the number of bytes actually skipped. + * + * @throws IOException + * If the stream is already closed or another IOException + * occurs. + */ + @Override + public long skip(long count) throws IOException { + return in.skip(count); + } +} diff --git a/sources/net.sf.j2s.java.core/src/java/io/InputStream.java b/sources/net.sf.j2s.java.core/src/java/io/InputStream.java index 96e7d6bb6..147a099c6 100644 --- a/sources/net.sf.j2s.java.core/src/java/io/InputStream.java +++ b/sources/net.sf.j2s.java.core/src/java/io/InputStream.java @@ -211,11 +211,11 @@ public long skip(long n) throws IOException { return skipped; } - /** - * BH: Allows resetting of the underlying stream (buffered only) - */ - public void resetStream() { - } - +// /** +// * BH: Allows resetting of the underlying stream (buffered only) +// */ +// public void resetStream() { +// } +// } diff --git a/sources/net.sf.j2s.java.core/src/java/io/PushbackInputStream.java b/sources/net.sf.j2s.java.core/src/java/io/PushbackInputStream.java index 368578e87..0ed8cd366 100644 --- a/sources/net.sf.j2s.java.core/src/java/io/PushbackInputStream.java +++ b/sources/net.sf.j2s.java.core/src/java/io/PushbackInputStream.java @@ -104,6 +104,16 @@ public PushbackInputStream(InputStream in, int size) { this.pos = size; } +// /** +// * BH: Added to allow full reset of a bundled stream +// */ +// @Override +// public void resetStream() { +// in.resetStream(); +// this.pos = 0; +// } +// + /** * Creates a PushbackInputStream * and saves its argument, the input stream diff --git a/sources/net.sf.j2s.java.core/src/java/io/StreamTokenizer.java b/sources/net.sf.j2s.java.core/src/java/io/StreamTokenizer.java new file mode 100644 index 000000000..d0996378e --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/java/io/StreamTokenizer.java @@ -0,0 +1,834 @@ +/* + * Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +package java.io; + +import java.util.Arrays; + +/** + * The StreamTokenizer class takes an input stream and + * parses it into "tokens", allowing the tokens to be + * read one at a time. The parsing process is controlled by a table + * and a number of flags that can be set to various states. The + * stream tokenizer can recognize identifiers, numbers, quoted + * strings, and various comment styles. + *

+ * Each byte read from the input stream is regarded as a character + * in the range '\u0000' through '\u00FF'. + * The character value is used to look up five possible attributes of + * the character: white space, alphabetic, + * numeric, string quote, and comment character. + * Each character can have zero or more of these attributes. + *

+ * In addition, an instance has four flags. These flags indicate: + *

    + *
  • Whether line terminators are to be returned as tokens or treated + * as white space that merely separates tokens. + *
  • Whether C-style comments are to be recognized and skipped. + *
  • Whether C++-style comments are to be recognized and skipped. + *
  • Whether the characters of identifiers are converted to lowercase. + *
+ *

+ * A typical application first constructs an instance of this class, + * sets up the syntax tables, and then repeatedly loops calling the + * nextToken method in each iteration of the loop until + * it returns the value TT_EOF. + * + * @author James Gosling + * @see java.io.StreamTokenizer#nextToken() + * @see java.io.StreamTokenizer#TT_EOF + * @since JDK1.0 + */ + +public class StreamTokenizer { + + /* Only one of these will be non-null */ + private Reader reader = null; + private InputStream input = null; + + private char buf[] = new char[20]; + + /** + * The next character to be considered by the nextToken method. May also + * be NEED_CHAR to indicate that a new character should be read, or SKIP_LF + * to indicate that a new character should be read and, if it is a '\n' + * character, it should be discarded and a second new character should be + * read. + */ + private int peekc = NEED_CHAR; + + private static final int NEED_CHAR = Integer.MAX_VALUE; + private static final int SKIP_LF = Integer.MAX_VALUE - 1; + + private boolean pushedBack; + private boolean forceLower; + /** The line number of the last token read */ + private int LINENO = 1; + + private boolean eolIsSignificantP = false; + private boolean slashSlashCommentsP = false; + private boolean slashStarCommentsP = false; + + private byte ctype[] = new byte[256]; + private static final byte CT_WHITESPACE = 1; + private static final byte CT_DIGIT = 2; + private static final byte CT_ALPHA = 4; + private static final byte CT_QUOTE = 8; + private static final byte CT_COMMENT = 16; + + /** + * After a call to the nextToken method, this field + * contains the type of the token just read. For a single character + * token, its value is the single character, converted to an integer. + * For a quoted string token, its value is the quote character. + * Otherwise, its value is one of the following: + *

    + *
  • TT_WORD indicates that the token is a word. + *
  • TT_NUMBER indicates that the token is a number. + *
  • TT_EOL indicates that the end of line has been read. + * The field can only have this value if the + * eolIsSignificant method has been called with the + * argument true. + *
  • TT_EOF indicates that the end of the input stream + * has been reached. + *
+ *

+ * The initial value of this field is -4. + * + * @see java.io.StreamTokenizer#eolIsSignificant(boolean) + * @see java.io.StreamTokenizer#nextToken() + * @see java.io.StreamTokenizer#quoteChar(int) + * @see java.io.StreamTokenizer#TT_EOF + * @see java.io.StreamTokenizer#TT_EOL + * @see java.io.StreamTokenizer#TT_NUMBER + * @see java.io.StreamTokenizer#TT_WORD + */ + public int ttype = TT_NOTHING; + + /** + * A constant indicating that the end of the stream has been read. + */ + public static final int TT_EOF = -1; + + /** + * A constant indicating that the end of the line has been read. + */ + public static final int TT_EOL = '\n'; + + /** + * A constant indicating that a number token has been read. + */ + public static final int TT_NUMBER = -2; + + /** + * A constant indicating that a word token has been read. + */ + public static final int TT_WORD = -3; + + /* A constant indicating that no token has been read, used for + * initializing ttype. FIXME This could be made public and + * made available as the part of the API in a future release. + */ + private static final int TT_NOTHING = -4; + + /** + * If the current token is a word token, this field contains a + * string giving the characters of the word token. When the current + * token is a quoted string token, this field contains the body of + * the string. + *

+ * The current token is a word when the value of the + * ttype field is TT_WORD. The current token is + * a quoted string token when the value of the ttype field is + * a quote character. + *

+ * The initial value of this field is null. + * + * @see java.io.StreamTokenizer#quoteChar(int) + * @see java.io.StreamTokenizer#TT_WORD + * @see java.io.StreamTokenizer#ttype + */ + public String sval; + + /** + * If the current token is a number, this field contains the value + * of that number. The current token is a number when the value of + * the ttype field is TT_NUMBER. + *

+ * The initial value of this field is 0.0. + * + * @see java.io.StreamTokenizer#TT_NUMBER + * @see java.io.StreamTokenizer#ttype + */ + public double nval; + + /** Private constructor that initializes everything except the streams. */ + private StreamTokenizer() { + wordChars('a', 'z'); + wordChars('A', 'Z'); + wordChars(128 + 32, 255); + whitespaceChars(0, ' '); + commentChar('/'); + quoteChar('"'); + quoteChar('\''); + parseNumbers(); + } + + /** + * Creates a stream tokenizer that parses the specified input + * stream. The stream tokenizer is initialized to the following + * default state: + *

    + *
  • All byte values 'A' through 'Z', + * 'a' through 'z', and + * '\u00A0' through '\u00FF' are + * considered to be alphabetic. + *
  • All byte values '\u0000' through + * '\u0020' are considered to be white space. + *
  • '/' is a comment character. + *
  • Single quote '\'' and double quote '"' + * are string quote characters. + *
  • Numbers are parsed. + *
  • Ends of lines are treated as white space, not as separate tokens. + *
  • C-style and C++-style comments are not recognized. + *
+ * + * @deprecated As of JDK version 1.1, the preferred way to tokenize an + * input stream is to convert it into a character stream, for example: + *
+     *   Reader r = new BufferedReader(new InputStreamReader(is));
+     *   StreamTokenizer st = new StreamTokenizer(r);
+     * 
+ * + * @param is an input stream. + * @see java.io.BufferedReader + * @see java.io.InputStreamReader + * @see java.io.StreamTokenizer#StreamTokenizer(java.io.Reader) + */ + @Deprecated + public StreamTokenizer(InputStream is) { + this(); + if (is == null) { + throw new NullPointerException(); + } + input = is; + } + + /** + * Create a tokenizer that parses the given character stream. + * + * @param r a Reader object providing the input stream. + * @since JDK1.1 + */ + public StreamTokenizer(Reader r) { + this(); + if (r == null) { + throw new NullPointerException(); + } + reader = r; + } + + /** + * Resets this tokenizer's syntax table so that all characters are + * "ordinary." See the ordinaryChar method + * for more information on a character being ordinary. + * + * @see java.io.StreamTokenizer#ordinaryChar(int) + */ + public void resetSyntax() { + for (int i = ctype.length; --i >= 0;) + ctype[i] = 0; + } + + /** + * Specifies that all characters c in the range + * low <= c <= high + * are word constituents. A word token consists of a word constituent + * followed by zero or more word constituents or number constituents. + * + * @param low the low end of the range. + * @param hi the high end of the range. + */ + public void wordChars(int low, int hi) { + if (low < 0) + low = 0; + if (hi >= ctype.length) + hi = ctype.length - 1; + while (low <= hi) + ctype[low++] |= CT_ALPHA; + } + + /** + * Specifies that all characters c in the range + * low <= c <= high + * are white space characters. White space characters serve only to + * separate tokens in the input stream. + * + *

Any other attribute settings for the characters in the specified + * range are cleared. + * + * @param low the low end of the range. + * @param hi the high end of the range. + */ + public void whitespaceChars(int low, int hi) { + if (low < 0) + low = 0; + if (hi >= ctype.length) + hi = ctype.length - 1; + while (low <= hi) + ctype[low++] = CT_WHITESPACE; + } + + /** + * Specifies that all characters c in the range + * low <= c <= high + * are "ordinary" in this tokenizer. See the + * ordinaryChar method for more information on a + * character being ordinary. + * + * @param low the low end of the range. + * @param hi the high end of the range. + * @see java.io.StreamTokenizer#ordinaryChar(int) + */ + public void ordinaryChars(int low, int hi) { + if (low < 0) + low = 0; + if (hi >= ctype.length) + hi = ctype.length - 1; + while (low <= hi) + ctype[low++] = 0; + } + + /** + * Specifies that the character argument is "ordinary" + * in this tokenizer. It removes any special significance the + * character has as a comment character, word component, string + * delimiter, white space, or number character. When such a character + * is encountered by the parser, the parser treats it as a + * single-character token and sets ttype field to the + * character value. + * + *

Making a line terminator character "ordinary" may interfere + * with the ability of a StreamTokenizer to count + * lines. The lineno method may no longer reflect + * the presence of such terminator characters in its line count. + * + * @param ch the character. + * @see java.io.StreamTokenizer#ttype + */ + public void ordinaryChar(int ch) { + if (ch >= 0 && ch < ctype.length) + ctype[ch] = 0; + } + + /** + * Specified that the character argument starts a single-line + * comment. All characters from the comment character to the end of + * the line are ignored by this stream tokenizer. + * + *

Any other attribute settings for the specified character are cleared. + * + * @param ch the character. + */ + public void commentChar(int ch) { + if (ch >= 0 && ch < ctype.length) + ctype[ch] = CT_COMMENT; + } + + /** + * Specifies that matching pairs of this character delimit string + * constants in this tokenizer. + *

+ * When the nextToken method encounters a string + * constant, the ttype field is set to the string + * delimiter and the sval field is set to the body of + * the string. + *

+ * If a string quote character is encountered, then a string is + * recognized, consisting of all characters after (but not including) + * the string quote character, up to (but not including) the next + * occurrence of that same string quote character, or a line + * terminator, or end of file. The usual escape sequences such as + * "\n" and "\t" are recognized and + * converted to single characters as the string is parsed. + * + *

Any other attribute settings for the specified character are cleared. + * + * @param ch the character. + * @see java.io.StreamTokenizer#nextToken() + * @see java.io.StreamTokenizer#sval + * @see java.io.StreamTokenizer#ttype + */ + public void quoteChar(int ch) { + if (ch >= 0 && ch < ctype.length) + ctype[ch] = CT_QUOTE; + } + + /** + * Specifies that numbers should be parsed by this tokenizer. The + * syntax table of this tokenizer is modified so that each of the twelve + * characters: + *

+     *      0 1 2 3 4 5 6 7 8 9 . -
+     * 
+ *

+ * has the "numeric" attribute. + *

+ * When the parser encounters a word token that has the format of a + * double precision floating-point number, it treats the token as a + * number rather than a word, by setting the ttype + * field to the value TT_NUMBER and putting the numeric + * value of the token into the nval field. + * + * @see java.io.StreamTokenizer#nval + * @see java.io.StreamTokenizer#TT_NUMBER + * @see java.io.StreamTokenizer#ttype + */ + public void parseNumbers() { + for (int i = '0'; i <= '9'; i++) + ctype[i] |= CT_DIGIT; + ctype['.'] |= CT_DIGIT; + ctype['-'] |= CT_DIGIT; + } + + /** + * Determines whether or not ends of line are treated as tokens. + * If the flag argument is true, this tokenizer treats end of lines + * as tokens; the nextToken method returns + * TT_EOL and also sets the ttype field to + * this value when an end of line is read. + *

+ * A line is a sequence of characters ending with either a + * carriage-return character ('\r') or a newline + * character ('\n'). In addition, a carriage-return + * character followed immediately by a newline character is treated + * as a single end-of-line token. + *

+ * If the flag is false, end-of-line characters are + * treated as white space and serve only to separate tokens. + * + * @param flag true indicates that end-of-line characters + * are separate tokens; false indicates that + * end-of-line characters are white space. + * @see java.io.StreamTokenizer#nextToken() + * @see java.io.StreamTokenizer#ttype + * @see java.io.StreamTokenizer#TT_EOL + */ + public void eolIsSignificant(boolean flag) { + eolIsSignificantP = flag; + } + + /** + * Determines whether or not the tokenizer recognizes C-style comments. + * If the flag argument is true, this stream tokenizer + * recognizes C-style comments. All text between successive + * occurrences of /* and */ are discarded. + *

+ * If the flag argument is false, then C-style comments + * are not treated specially. + * + * @param flag true indicates to recognize and ignore + * C-style comments. + */ + public void slashStarComments(boolean flag) { + slashStarCommentsP = flag; + } + + /** + * Determines whether or not the tokenizer recognizes C++-style comments. + * If the flag argument is true, this stream tokenizer + * recognizes C++-style comments. Any occurrence of two consecutive + * slash characters ('/') is treated as the beginning of + * a comment that extends to the end of the line. + *

+ * If the flag argument is false, then C++-style + * comments are not treated specially. + * + * @param flag true indicates to recognize and ignore + * C++-style comments. + */ + public void slashSlashComments(boolean flag) { + slashSlashCommentsP = flag; + } + + /** + * Determines whether or not word token are automatically lowercased. + * If the flag argument is true, then the value in the + * sval field is lowercased whenever a word token is + * returned (the ttype field has the + * value TT_WORD by the nextToken method + * of this tokenizer. + *

+ * If the flag argument is false, then the + * sval field is not modified. + * + * @param fl true indicates that all word tokens should + * be lowercased. + * @see java.io.StreamTokenizer#nextToken() + * @see java.io.StreamTokenizer#ttype + * @see java.io.StreamTokenizer#TT_WORD + */ + public void lowerCaseMode(boolean fl) { + forceLower = fl; + } + + /** Read the next character */ + private int read() throws IOException { + if (reader != null) + return reader.read(); + else if (input != null) + return input.read(); + else + throw new IllegalStateException(); + } + + /** + * Parses the next token from the input stream of this tokenizer. + * The type of the next token is returned in the ttype + * field. Additional information about the token may be in the + * nval field or the sval field of this + * tokenizer. + *

+ * Typical clients of this + * class first set up the syntax tables and then sit in a loop + * calling nextToken to parse successive tokens until TT_EOF + * is returned. + * + * @return the value of the ttype field. + * @exception IOException if an I/O error occurs. + * @see java.io.StreamTokenizer#nval + * @see java.io.StreamTokenizer#sval + * @see java.io.StreamTokenizer#ttype + */ + public int nextToken() throws IOException { + if (pushedBack) { + pushedBack = false; + return ttype; + } + byte ct[] = ctype; + sval = null; + + int c = peekc; + if (c < 0) + c = NEED_CHAR; + if (c == SKIP_LF) { + c = read(); + if (c < 0) + return ttype = TT_EOF; + if (c == '\n') + c = NEED_CHAR; + } + if (c == NEED_CHAR) { + c = read(); + if (c < 0) + return ttype = TT_EOF; + } + ttype = c; /* Just to be safe */ + + /* Set peekc so that the next invocation of nextToken will read + * another character unless peekc is reset in this invocation + */ + peekc = NEED_CHAR; + + int ctype = c < 256 ? ct[c] : CT_ALPHA; + while ((ctype & CT_WHITESPACE) != 0) { + if (c == '\r') { + LINENO++; + if (eolIsSignificantP) { + peekc = SKIP_LF; + return ttype = TT_EOL; + } + c = read(); + if (c == '\n') + c = read(); + } else { + if (c == '\n') { + LINENO++; + if (eolIsSignificantP) { + return ttype = TT_EOL; + } + } + c = read(); + } + if (c < 0) + return ttype = TT_EOF; + ctype = c < 256 ? ct[c] : CT_ALPHA; + } + + if ((ctype & CT_DIGIT) != 0) { + boolean neg = false; + if (c == '-') { + c = read(); + if (c != '.' && (c < '0' || c > '9')) { + peekc = c; + return ttype = '-'; + } + neg = true; + } + double v = 0; + int decexp = 0; + int seendot = 0; + while (true) { + if (c == '.' && seendot == 0) + seendot = 1; + else if ('0' <= c && c <= '9') { + v = v * 10 + (c - '0'); + decexp += seendot; + } else + break; + c = read(); + } + peekc = c; + if (decexp != 0) { + double denom = 10; + decexp--; + while (decexp > 0) { + denom *= 10; + decexp--; + } + /* Do one division of a likely-to-be-more-accurate number */ + v = v / denom; + } + nval = neg ? -v : v; + return ttype = TT_NUMBER; + } + + if ((ctype & CT_ALPHA) != 0) { + int i = 0; + do { + if (i >= buf.length) { + buf = Arrays.copyOf(buf, buf.length * 2); + } + buf[i++] = (char) c; + c = read(); + ctype = c < 0 ? CT_WHITESPACE : c < 256 ? ct[c] : CT_ALPHA; + } while ((ctype & (CT_ALPHA | CT_DIGIT)) != 0); + peekc = c; + sval = String.copyValueOf(buf, 0, i); + if (forceLower) + sval = sval.toLowerCase(); + return ttype = TT_WORD; + } + + if ((ctype & CT_QUOTE) != 0) { + ttype = c; + int i = 0; + /* Invariants (because \Octal needs a lookahead): + * (i) c contains char value + * (ii) d contains the lookahead + */ + int d = read(); + while (d >= 0 && d != ttype && d != '\n' && d != '\r') { + if (d == '\\') { + c = read(); + int first = c; /* To allow \377, but not \477 */ + if (c >= '0' && c <= '7') { + c = c - '0'; + int c2 = read(); + if ('0' <= c2 && c2 <= '7') { + c = (c << 3) + (c2 - '0'); + c2 = read(); + if ('0' <= c2 && c2 <= '7' && first <= '3') { + c = (c << 3) + (c2 - '0'); + d = read(); + } else + d = c2; + } else + d = c2; + } else { + switch (c) { + case 'a': + c = 0x7; + break; + case 'b': + c = '\b'; + break; + case 'f': + c = 0xC; + break; + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'v': + c = 0xB; + break; + } + d = read(); + } + } else { + c = d; + d = read(); + } + if (i >= buf.length) { + buf = Arrays.copyOf(buf, buf.length * 2); + } + buf[i++] = (char)c; + } + + /* If we broke out of the loop because we found a matching quote + * character then arrange to read a new character next time + * around; otherwise, save the character. + */ + peekc = (d == ttype) ? NEED_CHAR : d; + + sval = String.copyValueOf(buf, 0, i); + return ttype; + } + + if (c == '/' && (slashSlashCommentsP || slashStarCommentsP)) { + c = read(); + if (c == '*' && slashStarCommentsP) { + int prevc = 0; + while ((c = read()) != '/' || prevc != '*') { + if (c == '\r') { + LINENO++; + c = read(); + if (c == '\n') { + c = read(); + } + } else { + if (c == '\n') { + LINENO++; + c = read(); + } + } + if (c < 0) + return ttype = TT_EOF; + prevc = c; + } + return nextToken(); + } else if (c == '/' && slashSlashCommentsP) { + while ((c = read()) != '\n' && c != '\r' && c >= 0); + peekc = c; + return nextToken(); + } else { + /* Now see if it is still a single line comment */ + if ((ct['/'] & CT_COMMENT) != 0) { + while ((c = read()) != '\n' && c != '\r' && c >= 0); + peekc = c; + return nextToken(); + } else { + peekc = c; + return ttype = '/'; + } + } + } + + if ((ctype & CT_COMMENT) != 0) { + while ((c = read()) != '\n' && c != '\r' && c >= 0); + peekc = c; + return nextToken(); + } + + return ttype = c; + } + + /** + * Causes the next call to the nextToken method of this + * tokenizer to return the current value in the ttype + * field, and not to modify the value in the nval or + * sval field. + * + * @see java.io.StreamTokenizer#nextToken() + * @see java.io.StreamTokenizer#nval + * @see java.io.StreamTokenizer#sval + * @see java.io.StreamTokenizer#ttype + */ + public void pushBack() { + if (ttype != TT_NOTHING) /* No-op if nextToken() not called */ + pushedBack = true; + } + + /** + * Return the current line number. + * + * @return the current line number of this stream tokenizer. + */ + public int lineno() { + return LINENO; + } + + /** + * Returns the string representation of the current stream token and + * the line number it occurs on. + * + *

The precise string returned is unspecified, although the following + * example can be considered typical: + * + *

Token['a'], line 10
+ * + * @return a string representation of the token + * @see java.io.StreamTokenizer#nval + * @see java.io.StreamTokenizer#sval + * @see java.io.StreamTokenizer#ttype + */ + public String toString() { + String ret; + switch (ttype) { + case TT_EOF: + ret = "EOF"; + break; + case TT_EOL: + ret = "EOL"; + break; + case TT_WORD: + ret = sval; + break; + case TT_NUMBER: + ret = "n=" + nval; + break; + case TT_NOTHING: + ret = "NOTHING"; + break; + default: { + /* + * ttype is the first character of either a quoted string or + * is an ordinary character. ttype can definitely not be less + * than 0, since those are reserved values used in the previous + * case statements + */ + if (ttype < 256 && + ((ctype[ttype] & CT_QUOTE) != 0)) { + ret = sval; + break; + } + + char s[] = new char[3]; + s[0] = s[2] = '\''; + s[1] = (char) ttype; + ret = new String(s); + break; + } + } + return "Token[" + ret + "], line " + LINENO; + } + +} diff --git a/sources/net.sf.j2s.java.core/src/java/lang/Thread.java b/sources/net.sf.j2s.java.core/src/java/lang/Thread.java index 1c5eae66f..747470eee 100644 --- a/sources/net.sf.j2s.java.core/src/java/lang/Thread.java +++ b/sources/net.sf.j2s.java.core/src/java/lang/Thread.java @@ -204,7 +204,7 @@ private static synchronized int nextThreadNum() { * Thread ID */ private long tid; - + /* For generating thread ID */ private static long threadSeqNumber; public static Thread thisThread; @@ -277,7 +277,7 @@ private static synchronized long nextThreadID() { public static Thread currentThread() { /** * @j2sNative - *if (java.lang.Thread.thisThread == "working") + *if (java.lang.Thread.thisThread === "working") * return null; * * diff --git a/sources/net.sf.j2s.java.core/src/java/net/URL.java b/sources/net.sf.j2s.java.core/src/java/net/URL.java index 7a7534916..57607de32 100644 --- a/sources/net.sf.j2s.java.core/src/java/net/URL.java +++ b/sources/net.sf.j2s.java.core/src/java/net/URL.java @@ -1104,8 +1104,7 @@ public final InputStream openStream() throws IOException { * @throws IOException */ public Object getContent() throws IOException { - BufferedInputStream bis = AjaxURLConnection - .getAttachedStreamData((java.net.URL) (Object) this); + BufferedInputStream bis = AjaxURLConnection.getAttachedStreamData(this, false); return (bis == null ? openConnection().getInputStream() : bis); } diff --git a/sources/net.sf.j2s.java.core/src/java/util/zip/GZIPInputStream.java b/sources/net.sf.j2s.java.core/src/java/util/zip/GZIPInputStream.java index 9cf28b5b9..f4fe39273 100644 --- a/sources/net.sf.j2s.java.core/src/java/util/zip/GZIPInputStream.java +++ b/sources/net.sf.j2s.java.core/src/java/util/zip/GZIPInputStream.java @@ -80,6 +80,21 @@ public GZIPInputStream(InputStream in, int size) throws IOException { readHeader(in); } +// /** +// * BH: Addeed to allow full reset of a bundled stream +// */ +// @Override +// public void resetStream() { +// in.resetStream(); +// inflater = new Inflater().init(0, true); +// try { +// readHeader(in); +// } catch (IOException e) { +// // ignore +// } +// } +// + // /** // * Creates a new input stream with a default buffer size. // * @param in the input stream @@ -295,4 +310,6 @@ private void skipBytes(InputStream in, int n) throws IOException { n -= len; } } + + } diff --git a/sources/net.sf.j2s.java.core/src/java/util/zip/ZipInputStream.java b/sources/net.sf.j2s.java.core/src/java/util/zip/ZipInputStream.java index 4cd923245..6608987ca 100644 --- a/sources/net.sf.j2s.java.core/src/java/util/zip/ZipInputStream.java +++ b/sources/net.sf.j2s.java.core/src/java/util/zip/ZipInputStream.java @@ -92,6 +92,16 @@ public ZipInputStream(InputStream in) { this.zc = charset; } +// /** +// * BH: Addeed to allow full reset of a bundled stream +// */ +// @Override +// public void resetStream() { +// in.resetStream(); +// inflater = newInflater(); +// } +// + private static Inflater newInflater() { return (Inflater) new Inflater().init(0, true); } diff --git a/sources/net.sf.j2s.java.core/src/javajs/util/AjaxURLConnection.java b/sources/net.sf.j2s.java.core/src/javajs/util/AjaxURLConnection.java index 5135c7c38..0b038c337 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/util/AjaxURLConnection.java +++ b/sources/net.sf.j2s.java.core/src/javajs/util/AjaxURLConnection.java @@ -6,7 +6,6 @@ import java.net.URL; import java.net.URLConnection; -import javajs.api.ResettableStream; import javajs.api.js.J2SObjectInterface; /** @@ -74,48 +73,44 @@ public void outputString(String post) { @Override public InputStream getInputStream() { - BufferedInputStream bis = getAttachedStreamData(url); - if (bis != null) - return bis; - Object o = doAjax(true); - return ( - AU.isAB(o) ? Rdr.getBIS((byte[]) o) - : o instanceof SB ? Rdr.getBIS(Rdr.getBytesFromSB((SB) o)) - : o instanceof String ? Rdr.getBIS(((String) o).getBytes()) - : bis - ); + BufferedInputStream is = getAttachedStreamData(url, false); + return (is == null ? attachStreamData(url, doAjax(true)) : is); } - @SuppressWarnings({ "unused", "null" }) + /** - * J2S will attach a BufferedInputStream to any URL that is + * J2S will attach the data (String, SB, or byte[]) to any URL that is * retrieved using a ClassLoader. This improves performance by * not going back to the server every time a second time, since * the first time in Java is usually just to see if it exists. * - * This stream can be re-used, but it has to be reset. Java for some - * reason does not allow a BufferedInputStream to fully reset its - * inner streams. We enable that by force-casting the stream as a - * javax.io stream and then applying resetStream() to that. - * - * * @param url - * @return + * @return String, SB, or byte[] */ - public static BufferedInputStream getAttachedStreamData(URL url) { - BufferedInputStream bis = null; + public static BufferedInputStream getAttachedStreamData(URL url, boolean andDelete) { + + Object data = null; /** * @j2sNative * - * bis = url._streamData; + * data = url._streamData; + * if (andDelete) url._streamData = null; */ { } - if (bis != null) - ((ResettableStream) bis).resetStream(); - return bis; + return (data == null ? null : Rdr.toBIS(data)); } - /** + public static BufferedInputStream attachStreamData(URL url, Object o) { + /** + * @j2sNative + * + * url._streamData = o; + */ + + return (o == null ? null : Rdr.toBIS(o)); + } + + /** * @return javajs.util.SB or byte[], depending upon the file type */ public Object getContents() { diff --git a/sources/net.sf.j2s.java.core/src/javajs/util/BC.java b/sources/net.sf.j2s.java.core/src/javajs/util/BC.java index df9c9f9d6..5722efd08 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/util/BC.java +++ b/sources/net.sf.j2s.java.core/src/javajs/util/BC.java @@ -66,7 +66,7 @@ public static float intToFloat(int x) throws Exception { * if (o.fracIEEE == null) * o.setFracIEEE(); * var m = ((x & 0x7F800000) >> 23); - * return ((x & 0x80000000) == 0 ? 1 : -1) * o.shiftIEEE((x & 0x7FFFFF) | 0x800000, m - 149); + * return ((x & 0x80000000) == 0 ? 1 : -1) * o.shiftIEEE$D$I((x & 0x7FFFFF) | 0x800000, m - 149); * */ { @@ -96,7 +96,6 @@ public static float bytesToDoubleToFloat(byte[] bytes, int j, boolean isBigEndia /** * @j2sNative - * var o = javajs.util.BC; * var b1, b2, b3, b4, b5; * * if (isBigEndian) { @@ -115,8 +114,8 @@ public static float bytesToDoubleToFloat(byte[] bytes, int j, boolean isBigEndia * var s = ((b1 & 0x80) == 0 ? 1 : -1); * var e = (((b1 & 0x7F) << 4) | (b2 >> 4)) - 1026; * b2 = (b2 & 0xF) | 0x10; - * return s * (o.shiftIEEE(b2, e) + o.shiftIEEE(b3, e - 8) + o.shiftIEEE(b4, e - 16) - * + o.shiftIEEE(b5, e - 24)); + * return s * (C$.shiftIEEE$D$I(b2, e) +C$.shiftIEEE$D$I(b3, e - 8) + C$.shiftIEEE$D$I(b4, e - 16) + * + C$.shiftIEEE$D$I(b5, e - 24)); */ { double d; diff --git a/sources/net.sf.j2s.java.core/src/javajs/util/Rdr.java b/sources/net.sf.j2s.java.core/src/javajs/util/Rdr.java index 5fcc103a1..5d16ff340 100644 --- a/sources/net.sf.j2s.java.core/src/javajs/util/Rdr.java +++ b/sources/net.sf.j2s.java.core/src/javajs/util/Rdr.java @@ -199,14 +199,14 @@ private static Encoding getUTFEncoding(byte[] bytes) { private static Encoding getUTFEncodingForStream(BufferedInputStream is) throws IOException { - /** - * @j2sNative - * - * is.resetStream(); - * - */ - { - } +// /** +// * @j2sNative +// * +// * is.resetStream(); +// * +// */ +// { +// } byte[] abMagic = new byte[4]; abMagic[3] = 1; try{ @@ -302,15 +302,15 @@ public static boolean isZipB(byte[] bytes) { } public static byte[] getMagic(InputStream is, int n) { - byte[] abMagic = new byte[n]; - /** - * @j2sNative - * - * is.resetStream(); - * - */ - { - } + byte[] abMagic = new byte[n]; +// /** +// * @j2sNative +// * +// * is.resetStream(); +// * +// */ +// { +// } try { is.mark(n + 1); is.read(abMagic, 0, n); @@ -350,6 +350,14 @@ public static BufferedReader getBR(String string) { return new BufferedReader(new StringReader(string)); } + + public static BufferedInputStream toBIS(Object o) { + return (AU.isAB(o) ? getBIS((byte[]) o) + : o instanceof SB ? getBIS(Rdr.getBytesFromSB((SB) o)) + : o instanceof String ? getBIS(((String) o).getBytes()) : null); + } + + /** * Drill down into a GZIP stack until no more layers. * @param jzt diff --git a/sources/net.sf.j2s.java.core/src/javax/swing/JApplet.java b/sources/net.sf.j2s.java.core/src/javax/swing/JApplet.java index 4474d962c..f63b5caf6 100644 --- a/sources/net.sf.j2s.java.core/src/javax/swing/JApplet.java +++ b/sources/net.sf.j2s.java.core/src/javax/swing/JApplet.java @@ -133,7 +133,9 @@ public class JApplet extends Applet implements /* Accessible ,*/ */ public JApplet() { setFrameViewer(appletViewer); + uiClassID = "AppletUI"; setJApplet(); + updateUI(); } @@ -594,6 +596,12 @@ protected String paramString() { } + @Override + public void addNotify() { + super.addNotify(); + getLayeredPane().isFramedApplet = true; + + } ///////////////// // Accessibility support diff --git a/sources/net.sf.j2s.java.core/src/netscape/javascript/JSException.java b/sources/net.sf.j2s.java.core/src/netscape/javascript/JSException.java new file mode 100644 index 000000000..68ab7bd64 --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/netscape/javascript/JSException.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2002-2015 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package netscape.javascript; + +/** + * Stub for the JSException. This is part of the Applet + * LiveConnect simulation. + * + * TODO: we have to evaluate if it is possible to use plugin.jar from jdk + * + * @version $Revision: 9837 $ + * @author Ronald Brill + */ +@SuppressWarnings("serial") +public class JSException extends Exception { + public JSException(String msg) { + super(msg); + } +} diff --git a/sources/net.sf.j2s.java.core/src/netscape/javascript/JSObject.java b/sources/net.sf.j2s.java.core/src/netscape/javascript/JSObject.java new file mode 100644 index 000000000..41dc8ed37 --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/netscape/javascript/JSObject.java @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2002-2015 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package netscape.javascript; + +import java.applet.Applet; + +/** + * Stub for the JSException. This is part of the Applet + * LiveConnect simulation. + * + * TODO: we have to evaluate if it is possible to use plugin.jar from jdk + * + * @version $Revision: 9837 $ + * @author Ronald Brill + */ +public class JSObject { + + /** + * Empty stub. + * + * @param jsFuncName + * the paramString + * @param params + * the paramArrayOfObject + * @return result Object + * @throws JSException + * in case or error + */ + public Object call(final String jsFuncName, final Object[] params) throws JSException { + + Object ret = null; + try { + /** + * @j2sNative + * + * + * ret = self[jsFuncName].apply(null, params); + * + */ + } catch (Throwable t) { + throw new JSException("" + t + " evaluating " + jsFuncName); + } + return fixObject(ret); + } + + @SuppressWarnings("null") + private Object fixObject(Object ret) { + String type = null; + /** + * @j2sNative + * + * type = typeof ret; + */ + + switch (type) { + case "number": + return Double.valueOf("" + ret); + case "boolean": + return Boolean.valueOf("" + ret); + default: + return ret; + } + } + + /** + * Empty stub. + * + * @param paramString the paramString + * @return result Object + * @throws JSException in case or error + */ + public Object eval(String params) throws JSException { + Object ret = null; + try { + /** + * @j2sNative + * + * + * ret = eval(params); + * + */ + } catch (Throwable t) { + throw new JSException("" + t + " evaluating " + params); + } + return fixObject(ret); + } + + /** + * + * @param paramString the paramString + * @return result Object + * @throws JSException in case or error + */ + public Object getMember(String name) throws JSException { + Object ret = null; + try { + /** + * @j2sNative + * + * + * ret = self[name]; + * + */ + } catch (Throwable t) { + throw new JSException("" + t + " getMember " + name); + } + return fixObject(ret); + } + + /** + * @param name the paramString + * @param value the paramObject + * @throws JSException in case or error + */ + public void setMember(final String name, final Object value) throws JSException { + try { + /** + * @j2sNative + * + * + * self[name] = value; + * + */ + } catch (Throwable t) { + throw new JSException("" + t + " setMember " + name + " " + value); + } + } + + /** + * + * @param paramString the paramString + * @throws JSException in case or error + */ + public void removeMember(final String name) throws JSException { + try { + /** + * @j2sNative + * + * + * delete self[name]; + * + */ + } catch (Throwable t) { + throw new JSException("" + t + " removeMember " + name); + } + } + + /** + * Empty stub. + * + * @param paramInt the paramInt + * @return result Object + * @throws JSException in case or error + */ + public Object getSlot(final int paramInt) throws JSException { + throw new RuntimeException("Not yet implemented (netscape.javascript.JSObject.getSlot(int))."); + } + + /** + * Empty stub. + * + * @param paramInt the paramInt + * @param paramObject the paramObject + * @throws JSException in case or error + */ + public void setSlot(final int paramInt, final Object paramObject) throws JSException { + throw new RuntimeException("Not yet implemented (netscape.javascript.JSObject.setSlot(int, Object))."); + } + + /** + * Empty stub. + * + * @param paramApplet the paramApplet + * @return result Object + * @throws JSException in case or error + */ + public static JSObject getWindow(Applet paramApplet) throws JSException { + /** + * @j2sNative + * + * return self; + * + */ + { + return null; + } + } +} diff --git a/sources/net.sf.j2s.java.core/src/sun/audio/ContinuousAudioDataStream.java b/sources/net.sf.j2s.java.core/src/sun/audio/ContinuousAudioDataStream.java new file mode 100644 index 000000000..7264877aa --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/sun/audio/ContinuousAudioDataStream.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.audio; + +/** + * Create a continuous audio stream. This wraps a stream + * around an AudioData object, the stream is restarted + * at the beginning everytime the end is reached, thus + * creating continuous sound.

+ * For example: + *

+ *   AudioData data = AudioData.getAudioData(url);
+ *   ContinuousAudioDataStream audiostream = new ContinuousAudioDataStream(data);
+ *   AudioPlayer.player.start(audiostream);
+ * 
+ * + * @see AudioPlayer + * @see AudioData + * @author Arthur van Hoff + */ + +public + class ContinuousAudioDataStream extends AudioDataStream { + + + /** + * Create a continuous stream of audio. + */ + public ContinuousAudioDataStream(AudioData data) { + + super(data); + } + + + public int read() { + + int i = super.read(); + + if (i == -1) { + reset(); + i = super.read(); + } + + return i; + } + + + public int read(byte ab[], int i1, int j) { + + int k; + + for (k = 0; k < j; ) { + int i2 = super.read(ab, i1 + k, j - k); + if (i2 >= 0) k += i2; + else reset(); + } + + return k; + } + } diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSAppletViewer.java b/sources/net.sf.j2s.java.core/src/swingjs/JSAppletViewer.java index b507c69f7..ee8a6754e 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/JSAppletViewer.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/JSAppletViewer.java @@ -13,6 +13,7 @@ import java.awt.Insets; import java.awt.Toolkit; import java.awt.Window; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLStreamHandlerFactory; @@ -20,6 +21,7 @@ import java.util.Enumeration; import java.util.Hashtable; +import javax.imageio.ImageIO; import javax.swing.JApplet; import javax.swing.JComponent; import javax.swing.JFrame; @@ -233,7 +235,7 @@ public void appletResize(int width, int height) { final Dimension currentSize = new Dimension(currentAppletSize.width, currentAppletSize.height); currentAppletSize.width = width; currentAppletSize.height = height; - japplet.setBounds(0, 0, getWidth(), getHeight()); + japplet.setBounds(0, 0, width, height); japplet.getRootPane().setBounds(0, 0, getWidth(), getHeight()); japplet.getContentPane().setBounds(0, 0, getWidth(), getHeight()); ((JComponent) japplet.getContentPane()).revalidate(); @@ -301,8 +303,11 @@ public void setBounds(int x, int y, int width, int height) { @Override public Image getImage(URL url) { - // TODO Auto-generated method stub - return null; + try { + return ImageIO.read(url); + } catch (Throwable t) { + return null; + } } @Override diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSFrameViewer.java b/sources/net.sf.j2s.java.core/src/swingjs/JSFrameViewer.java index 0c0d6f9d3..9f222965d 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/JSFrameViewer.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/JSFrameViewer.java @@ -174,10 +174,13 @@ public void startHoverWatcher(boolean enable) { private static int canvasCount; + private Container topApp; public Graphics getGraphics(int wNew, int hNew) { if (wNew == 0 && top != null) { - wNew = Math.max (0, ((RootPaneContainer)top).getContentPane().getWidth()); - hNew = Math.max (0, ((RootPaneContainer)top).getContentPane().getHeight()); + if (topApp == null) + topApp = top; + wNew = Math.max (0, ((RootPaneContainer)topApp).getContentPane().getWidth()); + hNew = Math.max (0, ((RootPaneContainer)topApp).getContentPane().getHeight()); } int wOld = 0, hOld = 0; /** @@ -191,7 +194,7 @@ public Graphics getGraphics(int wNew, int hNew) { } if (wNew >= 0 && hNew >= 0 - && (wOld != wNew || hOld != hNew || canvas == null || jsgraphics == null)) { + && (wOld != wNew || hOld != hNew || canvas == null || jsgraphics == null)) { jsgraphics = new JSGraphics2D(canvas = newCanvas(wNew, hNew)); //top.repaint(0, 0, wNew, hNew); } @@ -202,10 +205,29 @@ public Graphics getGraphics(int wNew, int hNew) { public HTML5Canvas newCanvas(int width, int height) { if (isApplet) { // applets create their own canvas - canvas = html5Applet._getHtml5Canvas(); - return canvas; + HTML5Canvas c = html5Applet._getHtml5Canvas(); + if (c != null) { + return canvas = c; + } + } + if (topApp == null) + topApp = top; + JRootPane root = (JRootPane) (topApp.getComponentCount() > 0 ? topApp.getComponent(0) : null); + Container userFramedApplet = null, app = null; + if (root != null && root.getContentPane().getComponentCount() > 0) { + // check for applet in a frame + boolean appletInFrame = false; + app = (Container) root.getContentPane().getComponent(0); + /** + * @j2sNative + * + * appletInFrame = (app.uiClassID == "AppletUI"); + */ + if (appletInFrame) { + userFramedApplet = app; + root = (JRootPane) userFramedApplet.getComponent(0); + } } - JRootPane root = (JRootPane) (top.getComponentCount() > 0 ? top.getComponent(0) : null); DOMNode parent = (root == null ? null : ((JSComponentUI) root.getUI()).domNode); if (parent != null) DOMNode.remove(canvas); @@ -213,6 +235,13 @@ public HTML5Canvas newCanvas(int width, int height) { System.out.println("JSFrameViewer creating new canvas " + canvasId + ": " + width + " " + height); canvas = (HTML5Canvas) DOMNode.createElement("canvas", canvasId); + if (userFramedApplet != null) { + JSFrameViewer appViewer = + userFramedApplet.getFrameViewer(); + appViewer.setDisplay(canvas); + appViewer.topApp = app; + + } int iTop = (root == null ? 0 : root.getContentPane().getY()); DOMNode.setPositionAbsolute(canvas, iTop, 0); DOMNode.setStyles(canvas, "width", width + "px", "height", height + "px"); diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java b/sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java index 7b4ae09fe..9bee12ec8 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java @@ -106,7 +106,15 @@ public static Object getPostEventQueue(boolean isPost) { AppContext.EVENT_QUEUE_KEY)); } + /** + * From System.exit() + */ public static void exit() { + /** + * @j2sNative + * + * Thread.thisThread.group.systemExited = true; + */ JSUtil.getAppletViewer().exit(); } @@ -345,6 +353,7 @@ public static void dispatchEvent(AWTEvent event, Object src, boolean andWait) { /** * @j2sNative * + * * f = function() * { * if @@ -373,7 +382,9 @@ public static int dispatch(Object f, int msDelay, int id) { /** * @j2sNative * - * var thread = java.lang.Thread.thisThread; + * var thread = Thread.thisThread; + * if (thread.group.systemExited) + * return; * var thread0 = thread; * var id0 = SwingJS.eventID || 0; * var ff = function(_JSToolkit_setTimeout) { @@ -387,9 +398,10 @@ public static int dispatch(Object f, int msDelay, int id) { * } catch (e) { * var s = "JSToolkit.dispatch(" + id +"): " + e + "\n" + (e.getStackTrace ? e.getStackTrace() + "\n" : "") + (!!e.stack ? e.stack : ""); * System.out.println(s); - * alert(s)} + * alert(s); + * } * SwingJS.eventID = id0; - * java.lang.Thread.thisThread = thread0; + * Thread.thisThread = thread0; * }; * return (msDelay == -1 ? ff() : setTimeout(ff, msDelay)); * @@ -413,7 +425,9 @@ private static void invokeAndWait(JSFunction f, int id) { /** * @j2sNative * - * var thread = java.lang.Thread.thisThread; + * var thread = Thread.thisThread; + * if (thread.group.systemExited) + * return; * var thread0 = thread; * (function(_JSToolkit_setTimeout) { * var id0 = SwingJS.eventID || 0; @@ -424,7 +438,7 @@ private static void invokeAndWait(JSFunction f, int id) { * else * f(); * SwingJS.eventID = id0; - * java.lang.Thread.thisThread = thread0; + * Thread.thisThread = thread0; * })(); * * @@ -531,9 +545,9 @@ public static JSComponentUI getUI(Component c, boolean isQuiet) { if (ui == null) { String s = c.getClass().getName(); - if (!PT.isOneOf(s, ";javax.swing.Box.Filler;swingjs.JSApplet;")) + if (!PT.isOneOf(s, ";javax.swing.Box.Filler;")) System.out.println("[JSToolkit] Component " + s - + " has no corresponding JSComponentUI."); + + " has no corresponding JSComponentUI, class " + c.getClass().getName()); // Coerce JSComponentUI for this peer. // This is a JavaScript-only trick that would be // problematic in Java as well as in JavaScript. diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java b/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java index 8a2c06f85..aaba29e2b 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java @@ -11,6 +11,7 @@ import java.util.Map; import javajs.util.AU; +import javajs.util.AjaxURLConnection; import javajs.util.PT; import javajs.util.Rdr; import javajs.util.SB; @@ -81,19 +82,19 @@ private static Object getFileContents(Object uriOrJSFile) { } String uri = uriOrJSFile.toString(); Object data = getCachedFileData(uri); - if (data == null) - /** - * @j2sNative - * - */ - { + if (data == null) { + // for reference -- not used in JavaScript + + /** + * @j2sNative + * + */ try { - data = Rdr.streamToUTF8String(new BufferedInputStream((InputStream) new URL(uri).getContent())); + data = Rdr.streamToUTF8String((BufferedInputStream) new URL(uri).getContent()); } catch (Exception e) { } - } - else { + // bypasses AjaxURLConnection data = JSUtil.J2S._getFileData(uri, null, false, false); } return data; @@ -465,28 +466,13 @@ public static Locale getDefaultLocale(String language) { return new Locale(language, country, variant); } - @SuppressWarnings("unused") public static BufferedInputStream getURLInputStream(URL url, boolean andDelete) { - - BufferedInputStream bis = null; - /** - * @j2sNative - * - * bis = url._streamData; - * if (andDelete) - * url._streamData = null; - * - */ - {} - - if (bis == null) - try { - return (BufferedInputStream) (Object) url.openStream(); - } catch (IOException e) { - return null; - } - ((java.io.BufferedInputStream) (Object) bis).resetStream(); - return bis; + try { + BufferedInputStream bis = AjaxURLConnection.getAttachedStreamData(url, andDelete); + return (bis == null ? (BufferedInputStream) url.openStream() : bis); + } catch (IOException e) { + } + return null; } public static void showWebPage(URL url, Object target) { diff --git a/sources/net.sf.j2s.java.core/src/swingjs/jzlib/InflaterInputStream.java b/sources/net.sf.j2s.java.core/src/swingjs/jzlib/InflaterInputStream.java index d9244e64a..db11d62db 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/jzlib/InflaterInputStream.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/jzlib/InflaterInputStream.java @@ -76,6 +76,16 @@ public InflaterInputStream(InputStream in, Inflater inflater, int size, private byte[] byte1 = new byte[1]; + +// /** +// * BH: Addeed to allow full reset of a bundled stream +// */ +// @Override +// public void resetStream() { +// in.resetStream(); +// } +// + @Override public int read() throws IOException { if (closed) { @@ -89,6 +99,7 @@ public int read(byte[] b, int off, int len) throws IOException { return readInf(b, off, len); } + protected int readInf(byte[] b, int off, int len) throws IOException { if (closed) { throw new IOException("Stream closed"); diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSAppletUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSAppletUI.java new file mode 100644 index 000000000..eeb10915d --- /dev/null +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSAppletUI.java @@ -0,0 +1,15 @@ +package swingjs.plaf; + +import swingjs.api.js.DOMNode; + +public class JSAppletUI extends JSLightweightUI { + + @Override + protected DOMNode updateDOMNode() { + if (domNode == null) { + containerNode = domNode = newDOMObject("div", id); + } + return domNode; + } + +} diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java index 997c1b415..312fc06fc 100644 --- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java +++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java @@ -1103,8 +1103,9 @@ protected DOMNode setHTMLElementCUI() { if (jc.getFrameViewer().isApplet) { // If the applet's root pane, we insert it into the applet's content // layer div - swingjs.JSToolkit.getHTML5Applet(jc)._getContentLayer() - .appendChild(outerNode); + DOMNode cdiv = swingjs.JSToolkit.getHTML5Applet(jc)._getContentLayer(); + if (cdiv != null) + cdiv.appendChild(outerNode); // } else { // BH: pretty sure this next is totally unnecessary; would never run? // This is the root pane of a JFrame, JDialog, JWindow, etc. diff --git a/sources/net.sf.j2s.java.core/srcjs/js/SJSApplet.js b/sources/net.sf.j2s.java.core/srcjs/js/SwingJSApplet.js similarity index 99% rename from sources/net.sf.j2s.java.core/srcjs/js/SJSApplet.js rename to sources/net.sf.j2s.java.core/srcjs/js/SwingJSApplet.js index 39a0efc7a..6f53dfb3f 100644 --- a/sources/net.sf.j2s.java.core/srcjs/js/SJSApplet.js +++ b/sources/net.sf.j2s.java.core/srcjs/js/SwingJSApplet.js @@ -1,4 +1,4 @@ -// SJSApplet.js +// SwingJSApplet.js // generic SwingJS Applet diff --git a/sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js b/sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js index 042e0ded4..55e48f07f 100644 --- a/sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js +++ b/sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js @@ -1,4 +1,4 @@ -// j2sApplet.js (based on JmolCore.js) +// j2sCore.js (based on JmolCore.js) // BH 1/8/2018 10:27:46 PM SwingJS2 // BH 12/22/2017 1:18:42 PM adds j2sargs for setting arguments diff --git a/sources/net.sf.j2s.java.core/srcjs/js/j2sSwingJS.js b/sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js similarity index 99% rename from sources/net.sf.j2s.java.core/srcjs/js/j2sSwingJS.js rename to sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js index 0bd1a6df9..3fc6e5b7c 100644 --- a/sources/net.sf.j2s.java.core/srcjs/js/j2sSwingJS.js +++ b/sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js @@ -7,6 +7,9 @@ // Google closure compiler cannot handle Clazz.new or Clazz.super + +// BH 2/13/2018 6:24:44 AM adds String.copyValueOf (two forms) +// BH 2/7/2018 7:47:07 PM adds System.out.flush and System.err.flush // BH 2/1/2018 12:14:20 AM fix for new int[128][] not nulls // BH 1/9/2018 8:40:52 AM fully running SwingJS2; adds String.isEmpty() // BH 12/16/2017 5:53:47 PM refactored; removed older unused parts @@ -2511,7 +2514,10 @@ java.lang.System = System = { currentTimeMillis : function () { return new Date ().getTime (); }, - exit : function() { swingjs.JSToolkit && swingjs.JSToolkit.exit() }, + exit : function() { + debugger + swingjs.JSToolkit && swingjs.JSToolkit.exit() + }, gc : function() {}, // bh getProperties : function () { return System.props; @@ -2584,6 +2590,8 @@ Sys.out.printf = Sys.out.printf$S$OA = Sys.out.format = Sys.out.format$S$OA = fu Sys.out.println = Sys.out.println$O = Sys.out.println$Z = Sys.out.println$I = Sys.out.println$S = Sys.out.println$C = Sys.out.println = function(s) { +Sys.out.flush = function() {} + if (("" + s).indexOf("TypeError") >= 0) { debugger; } @@ -2626,6 +2634,8 @@ Sys.err.write = function (buf, offset, len) { Sys.err.print(String.instantialize(buf).substring(offset, offset+len)); }; +Sys.err.flush = function() {} + })(Clazz.Console, System); @@ -3629,8 +3639,6 @@ return Clazz.array(Byte.TYPE, -1, arrs); sp.contains$S = function(a) {return this.indexOf(a) >= 0} // bh added sp.compareTo$S = sp.compareTo$TT = function(a){return this > a ? 1 : this < a ? -1 : 0} // bh added - - sp.toCharArray=function(){ var result=new Array(this.length); for(var i=0;i= 0) { debugger; } @@ -15690,6 +15698,8 @@ Sys.err.write = function (buf, offset, len) { Sys.err.print(String.instantialize(buf).substring(offset, offset+len)); }; +Sys.err.flush = function() {} + })(Clazz.Console, System); @@ -16693,8 +16703,6 @@ return Clazz.array(Byte.TYPE, -1, arrs); sp.contains$S = function(a) {return this.indexOf(a) >= 0} // bh added sp.compareTo$S = sp.compareTo$TT = function(a){return this > a ? 1 : this < a ? -1 : 0} // bh added - - sp.toCharArray=function(){ var result=new Array(this.length); for(var i=0;i