javafx-mx

16:37:03.256 INFO  jd.cli.Main - Decompiling javafx-mx.jar
package com.oracle.javafx.jmx;

public abstract interface SGMXBean
{
  public abstract void pause();
  
  public abstract void resume();
  
  public abstract void step()
    throws IllegalStateException;
  
  public abstract String getWindows()
    throws IllegalStateException;
  
  public abstract String getSGTree(int paramInt)
    throws IllegalStateException;
  
  public abstract String getCSSInfo(int paramInt)
    throws IllegalStateException;
  
  public abstract String getBounds(int paramInt)
    throws IllegalStateException;
  
  public abstract void addHighlightedNode(int paramInt)
    throws IllegalStateException;
  
  public abstract void removeHighlightedNode(int paramInt)
    throws IllegalStateException;
  
  public abstract void addHighlightedRegion(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
    throws IllegalStateException;
  
  public abstract void removeHighlightedRegion(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
    throws IllegalStateException;
  
  public abstract String makeScreenShot(int paramInt)
    throws IllegalStateException;
  
  public abstract String makeScreenShot(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
    throws IllegalStateException;
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.SGMXBean
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx;

import com.sun.javafx.jmx.MXExtension;
import com.sun.scenario.animation.AnimationPulse;
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;

public final class MXExtensionImpl
  extends MXExtension
{
  public void intialize()
    throws Exception
  {
    MBeanServer localMBeanServer = ManagementFactory.getPlatformMBeanServer();
    
    localMBeanServer.registerMBean(new SGMXBeanImpl(), new ObjectName("com.oracle.javafx.jmx:type=SGBean"));
    
    localMBeanServer.registerMBean(AnimationPulse.getDefaultBean(), new ObjectName(":type=AnimationPulse"));
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.MXExtensionImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx;

import com.sun.javafx.tk.TKPulseListener;
import java.util.concurrent.CountDownLatch;

class SGMXBeanImpl$1
  implements TKPulseListener
{
  SGMXBeanImpl$1(SGMXBeanImpl paramSGMXBeanImpl, CountDownLatch paramCountDownLatch) {}
  
  public void pulse()
  {
    val$onePulseLatch.countDown();
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.SGMXBeanImpl.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx;

import com.oracle.javafx.jmx.json.JSONDocument;
import com.oracle.javafx.jmx.json.JSONDocument.Type;
import com.sun.javafx.css.StyleableProperty;
import com.sun.javafx.jmx.HighlightRegion;
import com.sun.javafx.jmx.MXNodeAlgorithm;
import com.sun.javafx.jmx.MXNodeAlgorithmContext;
import com.sun.javafx.tk.TKPulseListener;
import com.sun.javafx.tk.TKScene;
import com.sun.javafx.tk.Toolkit;
import com.sun.media.jfxmedia.AudioClip;
import com.sun.media.jfxmedia.MediaManager;
import com.sun.media.jfxmedia.MediaPlayer;
import com.sun.media.jfxmedia.events.PlayerStateEvent.PlayerState;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import javafx.beans.value.WritableValue;
import javafx.collections.ObservableList;
import javafx.geometry.Bounds;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Window;
import javax.imageio.ImageIO;

public class SGMXBeanImpl
  implements SGMXBean, MXNodeAlgorithm
{
  private static final String SGMX_NOT_PAUSED_TEXT = "Scene-graph is not PAUSED.";
  private static final String SGMX_CALL_GETSGTREE_FIRST = "You need to call getSGTree() first.";
  private boolean paused = false;
  private Map<Integer, Window> windowMap = null;
  private JSONDocument jwindows = null;
  private Map<Integer, Node> nodeMap = null;
  private JSONDocument[] jsceneGraphs = null;
  private Map<Scene, BufferedImage> scene2Image = null;
  private List<MediaPlayer> playersToResume = null;
  
  public void pause()
  {
    if (paused) {
      return;
    }
    paused = true;
    releaseAllStateObject();
    Toolkit localToolkit = Toolkit.getToolkit();
    localToolkit.pauseScenes();
    pauseMedia();
  }
  
  public void resume()
  {
    if (!paused) {
      return;
    }
    paused = false;
    releaseAllStateObject();
    Toolkit localToolkit = Toolkit.getToolkit();
    localToolkit.resumeScenes();
    resumeMedia();
  }
  
  public void step()
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    releaseAllStateObject();
    
    Toolkit localToolkit = Toolkit.getToolkit();
    final CountDownLatch localCountDownLatch = new CountDownLatch(1);
    
    localToolkit.setLastTkPulseListener(new TKPulseListener()
    {
      public void pulse()
      {
        localCountDownLatch.countDown();
      }
    });
    localToolkit.resumeScenes();
    try
    {
      localCountDownLatch.await();
    }
    catch (InterruptedException localInterruptedException) {}
    localToolkit.pauseScenes();
    localToolkit.setLastTkPulseListener(null);
  }
  
  public String getWindows()
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    importWindowsIfNeeded();
    return jwindows.toJSON();
  }
  
  public String getSGTree(int paramInt)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    importWindowsIfNeeded();
    if (nodeMap == null) {
      nodeMap = new LinkedHashMap();
    }
    if (jsceneGraphs[paramInt] == null)
    {
      Window localWindow = (Window)windowMap.get(Integer.valueOf(paramInt));
      importSGTree(localWindow.getScene().getRoot(), paramInt);
    }
    return jsceneGraphs[paramInt].toJSON();
  }
  
  public void addHighlightedNode(int paramInt)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    Toolkit.getToolkit().getHighlightedRegions().add(createHighlightRegion(paramInt));
    
    getNode(paramInt).getScene().impl_getPeer().markDirty();
  }
  
  public void removeHighlightedNode(int paramInt)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    Toolkit.getToolkit().getHighlightedRegions().remove(createHighlightRegion(paramInt));
    
    getNode(paramInt).getScene().impl_getPeer().markDirty();
  }
  
  public void addHighlightedRegion(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    TKScene localTKScene = getScene(paramInt).impl_getPeer();
    Toolkit.getToolkit().getHighlightedRegions().add(new HighlightRegion(localTKScene, paramDouble1, paramDouble2, paramDouble3, paramDouble4));
    
    localTKScene.markDirty();
  }
  
  public void removeHighlightedRegion(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    TKScene localTKScene = getScene(paramInt).impl_getPeer();
    Toolkit.getToolkit().getHighlightedRegions().remove(new HighlightRegion(localTKScene, paramDouble1, paramDouble2, paramDouble3, paramDouble4));
    
    localTKScene.markDirty();
  }
  
  private Node getNode(int paramInt)
  {
    if (nodeMap == null) {
      throw new IllegalStateException("You need to call getSGTree() first.");
    }
    Node localNode = (Node)nodeMap.get(Integer.valueOf(paramInt));
    if (localNode == null) {
      throw new IllegalArgumentException("Wrong node id.");
    }
    return localNode;
  }
  
  private Scene getScene(int paramInt)
  {
    if (windowMap == null) {
      throw new IllegalStateException("You need to call getSGTree() first.");
    }
    Window localWindow = (Window)windowMap.get(Integer.valueOf(paramInt));
    if (localWindow == null) {
      throw new IllegalArgumentException("Wrong window id.");
    }
    return localWindow.getScene();
  }
  
  private HighlightRegion createHighlightRegion(int paramInt)
  {
    Node localNode = getNode(paramInt);
    Bounds localBounds = localNode.localToScene(localNode.getBoundsInLocal());
    return new HighlightRegion(localNode.getScene().impl_getPeer(), localBounds.getMinX(), localBounds.getMinY(), localBounds.getWidth(), localBounds.getHeight());
  }
  
  public String makeScreenShot(int paramInt)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    if (nodeMap == null) {
      throw new IllegalStateException("You need to call getSGTree() first.");
    }
    Node localNode = (Node)nodeMap.get(Integer.valueOf(paramInt));
    if (localNode == null) {
      return null;
    }
    Scene localScene = localNode.getScene();
    Bounds localBounds = localNode.localToScene(localNode.getBoundsInLocal());
    return getScreenShotPath(localScene, localBounds.getMinX(), localBounds.getMinY(), localBounds.getWidth(), localBounds.getHeight());
  }
  
  public String makeScreenShot(int paramInt, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    if (nodeMap == null) {
      throw new IllegalStateException("You need to call getSGTree() first.");
    }
    Scene localScene = getScene(paramInt);
    return getScreenShotPath(localScene, paramDouble1, paramDouble2, paramDouble3, paramDouble4);
  }
  
  private String getScreenShotPath(Scene paramScene, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
  {
    if (scene2Image == null) {
      scene2Image = new LinkedHashMap();
    }
    BufferedImage localBufferedImage = (BufferedImage)scene2Image.get(paramScene);
    if (localBufferedImage == null)
    {
      localObject1 = paramScene.renderToImage(null, 1.0F, false);
      localObject2 = Image.impl_fromPlatformImage(localObject1);
      localBufferedImage = (BufferedImage)((Image)localObject2).impl_toExternalImage(BufferedImage.class);
      scene2Image.put(paramScene, localBufferedImage);
    }
    Object localObject1 = localBufferedImage.getSubimage((int)paramDouble1, (int)paramDouble2, (int)paramDouble3, (int)paramDouble4);
    
    Object localObject2 = null;
    try
    {
      localObject2 = File.createTempFile("jfx", ".png");
      ImageIO.write((RenderedImage)localObject1, "PNG", (File)localObject2);
      ((File)localObject2).deleteOnExit();
      return ((File)localObject2).getAbsolutePath();
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return null;
  }
  
  private void releaseAllStateObject()
  {
    clearWindowMap();
    jwindows = null;
    clearNodeMap();
    jsceneGraphs = null;
    clearScene2Image();
  }
  
  private void clearWindowMap()
  {
    if (windowMap != null)
    {
      windowMap.clear();
      windowMap = null;
    }
  }
  
  private void clearNodeMap()
  {
    if (nodeMap != null)
    {
      nodeMap.clear();
      nodeMap = null;
    }
  }
  
  private void clearScene2Image()
  {
    if (scene2Image != null)
    {
      scene2Image.clear();
      scene2Image = null;
    }
  }
  
  private void importWindowsIfNeeded()
  {
    if (windowMap == null)
    {
      windowMap = new LinkedHashMap();
      importWindows();
    }
  }
  
  private void importWindows()
  {
    int i = 0;
    Iterator localIterator = Window.impl_getWindows();
    
    jwindows = JSONDocument.createArray();
    while (localIterator.hasNext())
    {
      Window localWindow = (Window)localIterator.next();
      
      windowMap.put(Integer.valueOf(i), localWindow);
      
      JSONDocument localJSONDocument = JSONDocument.createObject();
      localJSONDocument.setNumber("id", Integer.valueOf(i));
      localJSONDocument.setString("type", localWindow.impl_getMXWindowType());
      jwindows.array().add(localJSONDocument);
      i++;
    }
    jsceneGraphs = new JSONDocument[i];
  }
  
  private void importSGTree(Node paramNode, int paramInt)
  {
    if (paramNode == null) {
      return;
    }
    jsceneGraphs[paramInt] = ((JSONDocument)paramNode.impl_processMXNode(this, new MXNodeAlgorithmContext(nodeMap.size())));
  }
  
  public String getCSSInfo(int paramInt)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    if (nodeMap == null) {
      throw new IllegalStateException("You need to call getSGTree() first.");
    }
    Node localNode = (Node)nodeMap.get(Integer.valueOf(paramInt));
    if (localNode == null) {
      return null;
    }
    JSONDocument localJSONDocument = new JSONDocument(JSONDocument.Type.OBJECT);
    
    List localList = StyleableProperty.getStyleables(localNode);
    for (StyleableProperty localStyleableProperty : localList) {
      processStyleableProperty(localStyleableProperty, localNode, localJSONDocument);
    }
    return localJSONDocument.toJSON();
  }
  
  private static void processStyleableProperty(StyleableProperty paramStyleableProperty, Node paramNode, JSONDocument paramJSONDocument)
  {
    List localList = paramStyleableProperty.getSubProperties();
    Object localObject;
    if ((localList != null) && (!localList.isEmpty())) {
      for (localObject = localList.iterator(); ((Iterator)localObject).hasNext();)
      {
        localStyleableProperty = (StyleableProperty)((Iterator)localObject).next();
        processStyleableProperty(localStyleableProperty, paramNode, paramJSONDocument);
      }
    }
    try
    {
      localObject = paramStyleableProperty.getWritableValue(paramNode);
      StyleableProperty localStyleableProperty = localObject != null ? ((WritableValue)localObject).getValue() : null;
      if (localStyleableProperty != null) {
        paramJSONDocument.setString(paramStyleableProperty.getProperty(), localStyleableProperty.toString());
      } else {
        paramJSONDocument.setString(paramStyleableProperty.getProperty(), "null");
      }
    }
    catch (Exception localException)
    {
      System.out.println(localException);
      localException.printStackTrace();
    }
  }
  
  private static String upcaseFirstLetter(String paramString)
  {
    return paramString.substring(0, 1).toUpperCase() + paramString.substring(1);
  }
  
  public String getBounds(int paramInt)
    throws IllegalStateException
  {
    if (!paused) {
      throw new IllegalStateException("Scene-graph is not PAUSED.");
    }
    if (nodeMap == null) {
      throw new IllegalStateException("You need to call getSGTree() first.");
    }
    Node localNode = (Node)nodeMap.get(Integer.valueOf(paramInt));
    if (localNode == null) {
      return null;
    }
    Bounds localBounds = localNode.localToScene(localNode.getBoundsInLocal());
    JSONDocument localJSONDocument = JSONDocument.createObject();
    localJSONDocument.setNumber("x", Double.valueOf(localBounds.getMinX()));
    localJSONDocument.setNumber("y", Double.valueOf(localBounds.getMinY()));
    localJSONDocument.setNumber("w", Double.valueOf(localBounds.getWidth()));
    localJSONDocument.setNumber("h", Double.valueOf(localBounds.getHeight()));
    
    return localJSONDocument.toJSON();
  }
  
  public Object processLeafNode(Node paramNode, MXNodeAlgorithmContext paramMXNodeAlgorithmContext)
  {
    return createJSONDocument(paramNode, paramMXNodeAlgorithmContext);
  }
  
  public Object processContainerNode(Parent paramParent, MXNodeAlgorithmContext paramMXNodeAlgorithmContext)
  {
    JSONDocument localJSONDocument1 = createJSONDocument(paramParent, paramMXNodeAlgorithmContext);
    
    ObservableList localObservableList = paramParent.getChildrenUnmodifiable();
    
    JSONDocument localJSONDocument2 = JSONDocument.createArray(localObservableList.size());
    localJSONDocument1.set("children", localJSONDocument2);
    for (int i = 0; i < localObservableList.size(); i++) {
      localJSONDocument2.set(i, (JSONDocument)((Node)localObservableList.get(i)).impl_processMXNode(this, paramMXNodeAlgorithmContext));
    }
    return localJSONDocument1;
  }
  
  private JSONDocument createJSONDocument(Node paramNode, MXNodeAlgorithmContext paramMXNodeAlgorithmContext)
  {
    int i = paramMXNodeAlgorithmContext.getNextInt();
    
    nodeMap.put(Integer.valueOf(i), paramNode);
    
    JSONDocument localJSONDocument = JSONDocument.createObject();
    localJSONDocument.setNumber("id", Integer.valueOf(i));
    localJSONDocument.setString("class", paramNode.getClass().getSimpleName());
    return localJSONDocument;
  }
  
  private void pauseMedia()
  {
    AudioClip.stopAllClips();
    
    List localList = MediaManager.getAllMediaPlayers();
    if (localList == null) {
      return;
    }
    if ((!localList.isEmpty()) && (playersToResume == null)) {
      playersToResume = new ArrayList();
    }
    for (MediaPlayer localMediaPlayer : localList) {
      if (localMediaPlayer.getState() == PlayerStateEvent.PlayerState.PLAYING)
      {
        localMediaPlayer.pause();
        playersToResume.add(localMediaPlayer);
      }
    }
  }
  
  private void resumeMedia()
  {
    if (playersToResume == null) {
      return;
    }
    for (MediaPlayer localMediaPlayer : playersToResume) {
      localMediaPlayer.play();
    }
    playersToResume.clear();
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.SGMXBeanImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

import java.util.Collections;
import java.util.List;
import java.util.Map;

final class ImmutableJSONDocument
  extends JSONDocument
{
  public ImmutableJSONDocument(JSONDocument.Type paramType)
  {
    super(paramType);
  }
  
  public List<Object> array()
  {
    return Collections.emptyList();
  }
  
  public Map<String, Object> object()
  {
    return Collections.emptyMap();
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.ImmutableJSONDocument
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

import java.util.Iterator;

class JSONDocument$IteratorWrapper
  implements Iterator<JSONDocument>
{
  final Iterator<Object> iterator;
  
  JSONDocument$IteratorWrapper(Iterator<Object> paramIterator)
  {
    iterator = paramIterator;
  }
  
  public void remove()
  {
    iterator.remove();
  }
  
  public JSONDocument next()
  {
    Object localObject = iterator.next();
    if ((localObject instanceof JSONDocument)) {
      return (JSONDocument)localObject;
    }
    return null;
  }
  
  public boolean hasNext()
  {
    return iterator.hasNext();
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONDocument.IteratorWrapper
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

public enum JSONDocument$Type
{
  ARRAY,  OBJECT;
  
  private JSONDocument$Type() {}
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONDocument.Type
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;

public class JSONDocument
  implements Iterable<JSONDocument>
{
  public static final String JSON_XPATH_URI = "http://javafx.com/json/xpath";
  public static final JSONDocument EMPTY_ARRAY = new ImmutableJSONDocument(Type.ARRAY);
  public static final JSONDocument EMPTY_OBJECT = new ImmutableJSONDocument(Type.OBJECT);
  private final Type type;
  private final List<Object> array;
  private final Map<String, Object> object;
  
  public static enum Type
  {
    ARRAY,  OBJECT;
    
    private Type() {}
  }
  
  public static JSONDocument createObject()
  {
    return new JSONDocument(Type.OBJECT, 0);
  }
  
  public static JSONDocument createArray()
  {
    return createArray(0);
  }
  
  public static JSONDocument createArray(int paramInt)
  {
    return new JSONDocument(Type.ARRAY, paramInt);
  }
  
  public JSONDocument(Type paramType)
  {
    this(paramType, 0);
  }
  
  private JSONDocument(Type paramType, int paramInt)
  {
    type = paramType;
    if (paramType == Type.ARRAY)
    {
      Vector localVector = new Vector(paramInt);
      localVector.setSize(paramInt);
      array = localVector;
      object = null;
    }
    else if (paramType == Type.OBJECT)
    {
      array = null;
      object = new LinkedHashMap();
    }
    else
    {
      array = null;
      object = null;
      throw new IllegalArgumentException();
    }
  }
  
  public Type type()
  {
    return type;
  }
  
  public List<Object> array()
  {
    if (type != Type.ARRAY) {
      return EMPTY_ARRAY.array();
    }
    return array;
  }
  
  public Map<String, Object> object()
  {
    if (type != Type.OBJECT) {
      return EMPTY_OBJECT.object();
    }
    return object;
  }
  
  public boolean isArray()
  {
    return (type == Type.ARRAY) && (array != null);
  }
  
  public boolean isObject()
  {
    return (type == Type.OBJECT) && (object != null);
  }
  
  public void toJSON(Writer paramWriter)
    throws IOException
  {
    printJSON(paramWriter, isArray() ? array() : object(), 0, false);
  }
  
  public String toJSON()
  {
    StringWriter localStringWriter = new StringWriter(4096);
    try
    {
      printJSON(localStringWriter, isArray() ? array() : object(), 0, false);
    }
    catch (IOException localIOException) {}
    return localStringWriter.getBuffer().toString();
  }
  
  private void printJSON(Writer paramWriter, Object paramObject, int paramInt, boolean paramBoolean)
    throws IOException
  {
    if ((paramObject instanceof JSONDocument))
    {
      JSONDocument localJSONDocument = (JSONDocument)paramObject;
      if (localJSONDocument.isArray()) {
        printArray(paramWriter, localJSONDocument.array(), paramInt, paramBoolean);
      } else if (localJSONDocument.isObject()) {
        printObject(paramWriter, localJSONDocument.object(), paramInt, paramBoolean);
      } else if (!$assertionsDisabled) {
        throw new AssertionError();
      }
    }
    else if ((paramObject instanceof List))
    {
      printArray(paramWriter, (List)paramObject, paramInt, paramBoolean);
    }
    else if ((paramObject instanceof Map))
    {
      printObject(paramWriter, (Map)paramObject, paramInt, paramBoolean);
    }
    else if ((paramObject instanceof String))
    {
      paramWriter.append("\"");
      printEscapedString(paramWriter, (String)paramObject);
      paramWriter.append("\"");
    }
    else if (paramObject != null)
    {
      paramWriter.append(paramObject.toString());
    }
    else
    {
      paramWriter.append("null");
    }
  }
  
  private void printArray(Writer paramWriter, List<Object> paramList, int paramInt, boolean paramBoolean)
    throws IOException
  {
    Iterator localIterator = paramList.iterator();
    int i = paramList.size();
    int j = 0;
    
    paramWriter.append("[");
    if (i > 1)
    {
      paramInt++;
      prettyPrint(paramWriter, paramInt, paramBoolean);
    }
    while (localIterator.hasNext())
    {
      printJSON(paramWriter, localIterator.next(), paramInt, paramBoolean);
      if (j < i - 1)
      {
        paramWriter.append(",");
        prettyPrint(paramWriter, paramInt, paramBoolean);
      }
      j++;
    }
    if (i > 1)
    {
      paramInt--;
      prettyPrint(paramWriter, paramInt, paramBoolean);
    }
    paramWriter.append("]");
  }
  
  private void printObject(Writer paramWriter, Map<String, Object> paramMap, int paramInt, boolean paramBoolean)
    throws IOException
  {
    Iterator localIterator = paramMap.entrySet().iterator();
    int i = paramMap.size();
    int j = 0;
    
    paramWriter.append("{");
    if (i > 1)
    {
      paramInt++;
      prettyPrint(paramWriter, paramInt, paramBoolean);
    }
    while (localIterator.hasNext())
    {
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      paramWriter.append("\"");
      paramWriter.append((CharSequence)localEntry.getKey());
      paramWriter.append("\":");
      
      Object localObject = localEntry.getValue();
      if ((paramBoolean) && (i > 1))
      {
        int k = 0;
        if ((localObject instanceof JSONDocument))
        {
          JSONDocument localJSONDocument = (JSONDocument)localObject;
          if (localJSONDocument.isArray()) {
            k = localJSONDocument.array().size();
          } else if (localJSONDocument.isObject()) {
            k = localJSONDocument.object().size();
          } else if (!$assertionsDisabled) {
            throw new AssertionError();
          }
        }
        if (k > 0) {
          prettyPrint(paramWriter, paramInt, paramBoolean);
        }
      }
      printJSON(paramWriter, localObject, paramInt, paramBoolean);
      if (j < i - 1)
      {
        paramWriter.append(",");
        prettyPrint(paramWriter, paramInt, paramBoolean);
      }
      j++;
    }
    if (i > 1)
    {
      paramInt--;
      prettyPrint(paramWriter, paramInt, paramBoolean);
    }
    paramWriter.append("}");
  }
  
  static void printEscapedString(Writer paramWriter, String paramString)
    throws IOException
  {
    char[] arrayOfChar = paramString.toCharArray();
    for (int i = 0; i < arrayOfChar.length; i++) {
      if (arrayOfChar[i] == '"')
      {
        paramWriter.append("\\\"");
      }
      else if (arrayOfChar[i] == '\'')
      {
        paramWriter.append("'");
      }
      else if (arrayOfChar[i] == '\\')
      {
        paramWriter.append("\\\\");
      }
      else if (arrayOfChar[i] == '/')
      {
        paramWriter.append("\\/");
      }
      else if (arrayOfChar[i] == '\007')
      {
        paramWriter.append("\\a");
      }
      else if (arrayOfChar[i] == '\b')
      {
        paramWriter.append("\\b");
      }
      else if (arrayOfChar[i] == '\t')
      {
        paramWriter.append("\\t");
      }
      else if (arrayOfChar[i] == '\n')
      {
        paramWriter.append("\\n");
      }
      else if (arrayOfChar[i] == '\013')
      {
        paramWriter.append("\\v");
      }
      else if (arrayOfChar[i] == '\f')
      {
        paramWriter.append("\\f");
      }
      else if (arrayOfChar[i] == '\r')
      {
        paramWriter.append("\\r");
      }
      else if (arrayOfChar[i] == 0)
      {
        paramWriter.append("\\0");
      }
      else if ((arrayOfChar[i] > '') && (arrayOfChar[i] < 65535))
      {
        paramWriter.append("\\u");
        paramWriter.append(String.format("%04X", new Object[] { Integer.valueOf(arrayOfChar[i]) }));
      }
      else
      {
        paramWriter.append(arrayOfChar[i]);
      }
    }
  }
  
  private void prettyPrint(Writer paramWriter, int paramInt, boolean paramBoolean)
    throws IOException
  {
    if (paramBoolean)
    {
      paramWriter.append("\n");
      for (int i = 0; i < paramInt; i++) {
        paramWriter.append(" ");
      }
    }
  }
  
  public String toString()
  {
    StringWriter localStringWriter = new StringWriter(4096);
    try
    {
      printJSON(localStringWriter, isArray() ? array() : object(), 0, true);
    }
    catch (IOException localIOException) {}
    return localStringWriter.getBuffer().toString();
  }
  
  public boolean equals(Object paramObject)
  {
    if ((paramObject instanceof JSONDocument))
    {
      JSONDocument localJSONDocument = (JSONDocument)paramObject;
      return isObject() ? object().equals(localJSONDocument.object()) : isArray() ? array().equals(localJSONDocument.array()) : false;
    }
    return false;
  }
  
  public int hashCode()
  {
    int i = 7;
    i = 89 * i + (isObject() ? object().hashCode() : isArray() ? array().hashCode() : 0);
    return i;
  }
  
  public JSONDocument get(String paramString)
  {
    if (object != null)
    {
      Object localObject = object().get(paramString);
      if ((localObject instanceof JSONDocument)) {
        return (JSONDocument)localObject;
      }
    }
    return EMPTY_OBJECT;
  }
  
  public JSONDocument get(int paramInt)
  {
    if (array != null)
    {
      Object localObject = array().get(paramInt);
      if ((localObject instanceof JSONDocument)) {
        return (JSONDocument)localObject;
      }
    }
    return EMPTY_ARRAY;
  }
  
  public Map<String, Object> getMap(String paramString)
  {
    Object localObject = get(paramString, JSONDocument.class);
    if ((localObject instanceof JSONDocument)) {
      return getMap((JSONDocument)localObject);
    }
    return EMPTY_OBJECT.object();
  }
  
  public Map<String, Object> getMap(int paramInt)
  {
    Object localObject = get(paramInt, JSONDocument.class);
    if ((localObject instanceof JSONDocument)) {
      return getMap((JSONDocument)localObject);
    }
    return EMPTY_OBJECT.object();
  }
  
  public List<Object> getList(String paramString)
  {
    Object localObject = get(paramString, JSONDocument.class);
    if ((localObject instanceof JSONDocument)) {
      return getList((JSONDocument)localObject);
    }
    return EMPTY_ARRAY.array();
  }
  
  public List<Object> getList(int paramInt)
  {
    Object localObject = get(paramInt, JSONDocument.class);
    if ((localObject instanceof JSONDocument)) {
      return getList((JSONDocument)localObject);
    }
    return EMPTY_ARRAY.array();
  }
  
  public String getString(String paramString)
  {
    return (String)get(paramString, String.class);
  }
  
  public String getString(int paramInt)
  {
    return (String)get(paramInt, String.class);
  }
  
  public Boolean getBoolean(String paramString)
  {
    return (Boolean)get(paramString, Boolean.class);
  }
  
  public Boolean getBoolean(int paramInt)
  {
    return (Boolean)get(paramInt, Boolean.class);
  }
  
  public Number getNumber(String paramString)
  {
    return (Number)get(paramString, Number.class);
  }
  
  public Number getNumber(int paramInt)
  {
    return (Number)get(paramInt, Number.class);
  }
  
  public boolean isNull(String paramString)
  {
    if (object != null) {
      return null == object().get(paramString);
    }
    return false;
  }
  
  public boolean isNull(int paramInt)
  {
    if (array != null) {
      return null == array().get(paramInt);
    }
    return false;
  }
  
  private Map<String, Object> getMap(JSONDocument paramJSONDocument)
  {
    if (paramJSONDocument != null) {
      return paramJSONDocument.object();
    }
    return EMPTY_OBJECT.object();
  }
  
  private List<Object> getList(JSONDocument paramJSONDocument)
  {
    if (paramJSONDocument != null) {
      return paramJSONDocument.array();
    }
    return EMPTY_ARRAY.array();
  }
  
  private Object get(String paramString, Class<?> paramClass)
  {
    if (object != null)
    {
      Object localObject = object().get(paramString);
      if (paramClass.isInstance(localObject)) {
        return paramClass.cast(localObject);
      }
    }
    return null;
  }
  
  private Object get(int paramInt, Class<?> paramClass)
  {
    if (array != null)
    {
      Object localObject = array().get(paramInt);
      if (paramClass.isInstance(localObject)) {
        return paramClass.cast(localObject);
      }
    }
    return null;
  }
  
  public JSONDocument set(String paramString, JSONDocument paramJSONDocument)
  {
    return (JSONDocument)set(paramString, paramJSONDocument, JSONDocument.class);
  }
  
  public JSONDocument set(int paramInt, JSONDocument paramJSONDocument)
  {
    return (JSONDocument)set(paramInt, paramJSONDocument, JSONDocument.class);
  }
  
  public String setString(String paramString1, String paramString2)
  {
    return (String)set(paramString1, paramString2, String.class);
  }
  
  public String setString(int paramInt, String paramString)
  {
    return (String)set(paramInt, paramString, String.class);
  }
  
  public Boolean setBoolean(String paramString, Boolean paramBoolean)
  {
    return (Boolean)set(paramString, paramBoolean, Boolean.class);
  }
  
  public Boolean setBoolean(int paramInt, Boolean paramBoolean)
  {
    return (Boolean)set(paramInt, paramBoolean, Boolean.class);
  }
  
  public Number setNumber(String paramString, Number paramNumber)
  {
    return (Number)set(paramString, paramNumber, Number.class);
  }
  
  public Number setNumber(int paramInt, Number paramNumber)
  {
    return (Number)set(paramInt, paramNumber, Number.class);
  }
  
  public Object setNull(String paramString)
  {
    if (object != null) {
      return object.put(paramString, null);
    }
    return null;
  }
  
  public Object setNull(int paramInt)
  {
    if (array != null) {
      return array.set(paramInt, null);
    }
    return null;
  }
  
  private Object set(String paramString, Object paramObject, Class<?> paramClass)
  {
    if ((object != null) && 
      (paramClass.isInstance(paramObject))) {
      return paramClass.cast(object().put(paramString, paramObject));
    }
    return null;
  }
  
  private Object set(int paramInt, Object paramObject, Class<?> paramClass)
  {
    if ((array != null) && 
      (paramClass.isInstance(paramObject))) {
      return paramClass.cast(array().set(paramInt, paramObject));
    }
    return null;
  }
  
  static class IteratorWrapper
    implements Iterator<JSONDocument>
  {
    final Iterator<Object> iterator;
    
    IteratorWrapper(Iterator<Object> paramIterator)
    {
      iterator = paramIterator;
    }
    
    public void remove()
    {
      iterator.remove();
    }
    
    public JSONDocument next()
    {
      Object localObject = iterator.next();
      if ((localObject instanceof JSONDocument)) {
        return (JSONDocument)localObject;
      }
      return null;
    }
    
    public boolean hasNext()
    {
      return iterator.hasNext();
    }
  }
  
  public IteratorWrapper iterator()
  {
    return new IteratorWrapper(isObject() ? object().values().iterator() : array().iterator());
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONDocument
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

public class JSONException
  extends RuntimeException
{
  private final int line;
  private final int column;
  
  public JSONException(Throwable paramThrowable, int paramInt1, int paramInt2)
  {
    super(paramThrowable);
    line = paramInt1;
    column = paramInt2;
  }
  
  public JSONException(String paramString, int paramInt1, int paramInt2)
  {
    super(paramString);
    line = paramInt1;
    column = paramInt2;
  }
  
  public int line()
  {
    return line;
  }
  
  public int column()
  {
    return column;
  }
  
  public String toString()
  {
    return "(" + line + "," + column + ") " + super.toString();
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

import com.oracle.javafx.jmx.json.impl.JSONStreamReaderImpl;
import java.io.Reader;
import java.io.Writer;

public class JSONFactory
{
  private static final JSONFactory INSTANCE = new JSONFactory();
  
  public static JSONFactory instance()
  {
    return INSTANCE;
  }
  
  public JSONReader makeReader(Reader paramReader)
    throws JSONException
  {
    return new JSONStreamReaderImpl(paramReader);
  }
  
  public JSONWriter makeWriter(Writer paramWriter)
  {
    return new JSONWriter(paramWriter);
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

public enum JSONReader$EventType
{
  ERROR,  START_OBJECT,  END_OBJECT,  STRING,  START_DOCUMENT,  END_DOCUMENT,  START_ARRAY,  START_ARRAY_ELEMENT,  END_ARRAY_ELEMENT,  END_ARRAY,  NUMBER,  INTEGER,  TRUE,  FALSE,  NULL,  START_VALUE,  END_VALUE;
  
  private JSONReader$EventType() {}
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONReader.EventType
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

import java.util.Iterator;

public abstract interface JSONReader
  extends Iterable<EventType>, Iterator<EventType>
{
  public abstract String key();
  
  public abstract String value();
  
  public abstract EventType next(String paramString, int paramInt);
  
  public abstract void close();
  
  public abstract int line();
  
  public abstract int column();
  
  public abstract long offset();
  
  public abstract int depth();
  
  public abstract String[] path();
  
  public abstract JSONDocument build();
  
  public static enum EventType
  {
    ERROR,  START_OBJECT,  END_OBJECT,  STRING,  START_DOCUMENT,  END_DOCUMENT,  START_ARRAY,  START_ARRAY_ELEMENT,  END_ARRAY_ELEMENT,  END_ARRAY,  NUMBER,  INTEGER,  TRUE,  FALSE,  NULL,  START_VALUE,  END_VALUE;
    
    private EventType() {}
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONReader
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

class JSONWriter$Container
{
  JSONWriter.ContainerType type;
  boolean first;
  
  JSONWriter$Container(JSONWriter.ContainerType paramContainerType)
  {
    type = paramContainerType;
    first = true;
  }
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONWriter.Container
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

 enum JSONWriter$ContainerType
{
  ARRAY,  OBJECT;
  
  private JSONWriter$ContainerType() {}
}

/* Location:
 * Qualified Name:     com.oracle.javafx.jmx.json.JSONWriter.ContainerType
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.oracle.javafx.jmx.json;

import com.oracle.javafx.jmx.json.impl.JSONMessages;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Stack;

public class JSONWriter
{
  private final Writer writer;
  
  private static enum ContainerType
  {
    ARRAY,  OBJECT;
    
    private ContainerType() {}
  }
  
  private static class Container
  {
    JSONWriter.ContainerType type;
    boolean first;
    
    Container(JSONWriter.ContainerType paramContainerType)
    {
      type = paramContainerType;
      first = true;
    }
  }
  
  private Stack<Container> where = new Stack();
  
  JSONWriter(Writer paramWriter)
  {
    writer = paramWriter;
  }
  
  public JSONWriter startObject()
    throws IOException
  {
    writeSeparatorIfNeeded();
    writer.write("{");
    where.push(new Container(ContainerType.OBJECT));
    return this;
  }
  
  public JSONWriter startObject(String paramString)
    throws IOException
  {
    if (where.peek()).type != ContainerType.OBJECT) {
      throw new IllegalStateException(JSONMessages.locali
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd