Java 类weka.core.scripting.Jython 实例源码

项目:repo.kmeanspp.silhouette_score    文件:SerializedObject.java   
/**
  * Returns a serialized object. Uses org.python.util.PythonObjectInputStream 
  * for Jython objects (read 
  * <a href="http://aspn.activestate.com/ASPN/Mail/Message/Jython-users/1001401">here</a>
  * for more details).
  *
  * @return the restored object
  * @exception Exception if the object couldn't be restored
  */ 
 public Object getObject() {

   try {
     ByteArrayInputStream istream = new ByteArrayInputStream(m_storedObjectArray);
     ObjectInputStream p;
     Object toReturn = null;
     if (m_isJython) {
if (!m_isCompressed)
  toReturn = Jython.deserialize(new BufferedInputStream(istream));
else 
  toReturn = Jython.deserialize(new BufferedInputStream(new GZIPInputStream(istream)));
     }
     else {
if (!m_isCompressed)
  p = new ObjectInputStream(new BufferedInputStream(istream));
else 
  p = new ObjectInputStream(new BufferedInputStream(new GZIPInputStream(istream)));
toReturn = p.readObject();
     }
     istream.close();
     return toReturn;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
项目:autoweka    文件:SerializedObject.java   
/**
  * Returns a serialized object. Uses org.python.util.PythonObjectInputStream 
  * for Jython objects (read 
  * <a href="http://aspn.activestate.com/ASPN/Mail/Message/Jython-users/1001401">here</a>
  * for more details).
  *
  * @return the restored object
  * @exception Exception if the object couldn't be restored
  */ 
 public Object getObject() {

   try {
     ByteArrayInputStream istream = new ByteArrayInputStream(m_storedObjectArray);
     ObjectInputStream p;
     Object toReturn = null;
     if (m_isJython) {
if (!m_isCompressed)
  toReturn = Jython.deserialize(new BufferedInputStream(istream));
else 
  toReturn = Jython.deserialize(new BufferedInputStream(new GZIPInputStream(istream)));
     }
     else {
if (!m_isCompressed)
  p = new ObjectInputStream(new BufferedInputStream(istream));
else 
  p = new ObjectInputStream(new BufferedInputStream(new GZIPInputStream(istream)));
toReturn = p.readObject();
     }
     istream.close();
     return toReturn;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
项目:umple    文件:SerializedObject.java   
/**
  * Returns a serialized object. Uses org.python.util.PythonObjectInputStream 
  * for Jython objects (read 
  * <a href="http://aspn.activestate.com/ASPN/Mail/Message/Jython-users/1001401">here</a>
  * for more details).
  *
  * @return the restored object
  * @exception Exception if the object couldn't be restored
  */ 
 public Object getObject() {

   try {
     ByteArrayInputStream istream = new ByteArrayInputStream(m_storedObjectArray);
     ObjectInputStream p;
     Object toReturn = null;
     if (m_isJython) {
if (!m_isCompressed)
  toReturn = Jython.deserialize(new BufferedInputStream(istream));
else 
  toReturn = Jython.deserialize(new BufferedInputStream(new GZIPInputStream(istream)));
     }
     else {
if (!m_isCompressed)
  p = new ObjectInputStream(new BufferedInputStream(istream));
else 
  p = new ObjectInputStream(new BufferedInputStream(new GZIPInputStream(istream)));
toReturn = p.readObject();
     }
     istream.close();
     return toReturn;
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
项目:repo.kmeanspp.silhouette_score    文件:JythonScript.java   
/**
 * Performs pre-execution checks.
 * <p/>
 * This method checks whether Jython is available (throws an exception if
 * not).
 * 
 * @param args optional commandline arguments
 * @throws Exception if checks fail
 */
@Override
protected void preCheck(String[] args) throws Exception {
  super.preCheck(args);

  if (!Jython.isPresent()) {
    throw new Exception("Jython classes are not present in CLASSPATH!");
  }
}
项目:autoweka    文件:JythonScript.java   
/**
 * Performs pre-execution checks.
 * <p/>
 * This method checks whether Jython is available (throws an exception if not).
 * 
 * @param args  optional commandline arguments
 * @throws Exception    if checks fail
 */
protected void preCheck(String[] args) throws Exception {
  super.preCheck(args);

  if (!Jython.isPresent())
    throw new Exception("Jython classes are not present in CLASSPATH!");
}
项目:umple    文件:JythonScript.java   
/**
 * Performs pre-execution checks.
 * <p/>
 * This method checks whether Jython is available (throws an exception if
 * not).
 * 
 * @param args optional commandline arguments
 * @throws Exception if checks fail
 */
@Override
protected void preCheck(String[] args) throws Exception {
  super.preCheck(args);

  if (!Jython.isPresent()) {
    throw new Exception("Jython classes are not present in CLASSPATH!");
  }
}
项目:repo.kmeanspp.silhouette_score    文件:JythonScript.java   
/**
 * Returns whether scripts can be executed, i.e., Jython is present.
 * 
 * @return true if scripts can be executed
 */
@Override
protected boolean canExecuteScripts() {
  return Jython.isPresent();
}
项目:autoweka    文件:JythonScript.java   
/**
 * Returns whether scripts can be executed, i.e., Jython is present.
 * 
 * @return      true if scripts can be executed
 */
protected boolean canExecuteScripts() {
  return Jython.isPresent();
}
项目:umple    文件:JythonScript.java   
/**
 * Returns whether scripts can be executed, i.e., Jython is present.
 * 
 * @return true if scripts can be executed
 */
@Override
protected boolean canExecuteScripts() {
  return Jython.isPresent();
}