public static void showSession(HttpServletRequest req, PrintStream out) {

    // res.setContentType("text/html");

    // Get the current session object, create one if necessary
    HttpSession session = req.getSession();

    out.println("Session id: " + session.getId());
    out.println(" session.isNew(): " + session.isNew());
    out.println(" session.getMaxInactiveInterval(): " + session.getMaxInactiveInterval() + " secs");
    out.println(
        " session.getCreationTime(): "
            + session.getCreationTime()
            + " ("
            + new Date(session.getCreationTime())
            + ")");
    out.println(
        " session.getLastAccessedTime(): "
            + session.getLastAccessedTime()
            + " ("
            + new Date(session.getLastAccessedTime())
            + ")");
    out.println(" req.isRequestedSessionIdFromCookie: " + req.isRequestedSessionIdFromCookie());
    out.println(" req.isRequestedSessionIdFromURL: " + req.isRequestedSessionIdFromURL());
    out.println(" req.isRequestedSessionIdValid: " + req.isRequestedSessionIdValid());

    out.println("Saved session Attributes:");
    Enumeration atts = session.getAttributeNames();
    while (atts.hasMoreElements()) {
      String name = (String) atts.nextElement();
      out.println(" " + name + ": " + session.getAttribute(name) + "<BR>");
    }
  }
  private static void showThreads(PrintStream pw, ThreadGroup g, Thread current) {
    int nthreads = g.activeCount();
    pw.println("\nThread Group = " + g.getName() + " activeCount= " + nthreads);
    Thread[] tarray = new Thread[nthreads];
    int n = g.enumerate(tarray, false);

    for (int i = 0; i < n; i++) {
      Thread thread = tarray[i];
      ClassLoader loader = thread.getContextClassLoader();
      String loaderName = (loader == null) ? "Default" : loader.getClass().getName();
      Thread.State state = thread.getState();
      long id = thread.getId();
      pw.print("   " + id + " " + thread.getName() + " " + state + " " + loaderName);
      if (thread == current) pw.println(" **** CURRENT ***");
      else pw.println();
    }

    int ngroups = g.activeGroupCount();
    ThreadGroup[] garray = new ThreadGroup[ngroups];
    int ng = g.enumerate(garray, false);
    for (int i = 0; i < ng; i++) {
      ThreadGroup nested = garray[i];
      showThreads(pw, nested, current);
    }
  }
Beispiel #3
0
  /**
   * dump the message to a PrintStream. The output is sorta XML, intended to be easily parsed. <br>
   * Each component is responsible for its own dump function, ISOMsg just calls dump on every valid
   * field.
   *
   * @param p - print stream
   * @param indent - optional indent string
   */
  public void dump(PrintStream p, String indent) {
    ISOComponent c;
    p.print(indent + "<" + XMLPackager.ISOMSG_TAG);
    switch (direction) {
      case INCOMING:
        p.print(" direction=\"incoming\"");
        break;
      case OUTGOING:
        p.print(" direction=\"outgoing\"");
        break;
    }
    if (fieldNumber != -1) p.print(" " + XMLPackager.ID_ATTR + "=\"" + fieldNumber + "\"");
    p.println(">");
    String newIndent = indent + "  ";
    if (getPackager() != null) {
      p.println(newIndent + "<!-- " + getPackager().getDescription() + " -->");
    }
    if (header instanceof Loggeable) ((Loggeable) header).dump(p, newIndent);

    for (int i = 0; i <= maxField; i++) {
      if ((c = (ISOComponent) fields.get(i)) != null) c.dump(p, newIndent);
      //
      // Uncomment to include bitmaps within logs
      //
      // if (i == 0) {
      //  if ((c = (ISOComponent) fields.get (new Integer (-1))) != null)
      //    c.dump (p, newIndent);
      // }
      //
    }

    p.println(indent + "</" + XMLPackager.ISOMSG_TAG + ">");
  }
Beispiel #4
0
  /**
   * There are two things we need to check
   *
   * <ul>
   *   <li>files created or modified since last build time, we only need to check the source folder
   *   <li>file deleted since last build time, we have to compare source and destination folder
   * </ul>
   */
  @Override
  public boolean pollChanges(
      AbstractProject project, Launcher launcher, FilePath workspace, TaskListener listener)
      throws IOException, InterruptedException {

    long start = System.currentTimeMillis();

    PrintStream log = launcher.getListener().getLogger();
    log.println("FSSCM.pollChange: " + path);

    AllowDeleteList allowDeleteList = new AllowDeleteList(project.getRootDir());
    // we will only delete a file if it is listed in the allowDeleteList
    // ie. we will only delete a file if it is copied by us
    if (allowDeleteList.fileExists()) {
      allowDeleteList.load();
    } else {
      // watch list save file doesn't exist
      // we will assuem all existing files are under watch
      // ie. everything can be deleted
      Set<String> existingFiles = workspace.act(new RemoteListDir());
      allowDeleteList.setList(existingFiles);
    }

    RemoteFolderDiff.PollChange callable = new RemoteFolderDiff.PollChange();
    setupRemoteFolderDiff(callable, project, allowDeleteList.getList());

    boolean changed = workspace.act(callable);
    String str = callable.getLog();
    if (str.length() > 0) log.println(str);
    log.println("FSSCM.pollChange return " + changed);

    log.println(
        "FSSCM.poolChange completed in " + formatDurration(System.currentTimeMillis() - start));
    return changed;
  }
 /** Try the given mail server, writing output to the given PrintStream */
 public static void process(String suspect_relay, PrintStream pw) {
   pw.println("processs: trying: " + suspect_relay);
   try {
     // Redirect all output from mail API to the given stream.
     System.setOut(pw);
     System.setErr(pw);
     Sender2 sm = new Sender2(suspect_relay);
     sm.addRecipient("*****@*****.**");
     sm.setFrom(MY_TARGET);
     sm.setSubject("Testing for open mail relay, see " + RSS_SITE);
     sm.setBody(
         "This mail is an attempt to confirm that site "
             + suspect_relay
             + "\n"
             + "is in fact an open mail relay site.\n"
             + "For more information on the problem of open mail relays,\n"
             + "please visit site "
             + RSS_SITE
             + "\n"
             + "Please join the fight against spam by closing all open mail relays!\n"
             + "If this open relay has been closed, please accept our thanks.\n");
     sm.sendFile();
   } catch (MessagingException e) {
     pw.println(e);
   } catch (Exception e) {
     pw.println(e);
   }
 }
  public static void xlsl() {
    out.println("xlsl instruction");
    // XLSL1 shifts AC left one bit, sets/resets the flags
    // if AC is negative, carry bit will be true
    if ((short) AC < 0) {
      flag[1] = true;
    } else {
      flag[1] = false;
    }
    // setting overflow flag
    // if it changes sign, overflow
    if ((short) (0xFFFF & AC) > 0 && (short) ((0xFFFF & AC) << 1) < 0) {
      flag[2] = true;
    } else if ((short) (0xFFFF & AC) < 0 && (short) ((0xFFFF & AC) << 1) > 0) {
      flag[2] = true;
    } else {
      flag[2] = false;
    }
    AC += -(0xFFFF & AC) + (0xFFFF & AC << 1);

    out.println(0xFFFF & AC);
    // set the flags
    setFlagsXRotS();
    out.print("xlsl1 AC = " + AC);
    printzcvn();
  }
 public static void viewTagInfo(String inurl, String tag) throws Exception {
   // pr = new PrintStream(new FileOutputStream("/semplest/lluis/keywordExp/urldata.txt"));
   pr = System.out;
   long start = System.currentTimeMillis();
   pr.println(inurl + "****************************************************************");
   printList(cleanUrlText(TextUtils.HTMLText(inurl, tag)));
   String urls = TextUtils.HTMLLinkString(inurl, inurl);
   String[] url = urls.split("\\s+");
   Set<String> urlMap = new HashSet<String>(url.length);
   urlMap.add(inurl);
   for (String ur : url) {
     if (!urlMap.contains(ur)) {
       pr.println(ur + "***************************************************************");
       try {
         printList(cleanUrlText(TextUtils.HTMLText(ur, tag)));
       } catch (Exception e) {
         System.out.println("Error with url :" + ur);
         e.printStackTrace();
         logger.error("Problem", e);
       }
       urlMap.add(ur);
     }
   }
   pr.println("Time elapsed" + (start - System.currentTimeMillis()));
 }
Beispiel #8
0
 static void printFooter(PrintStream file) {
   file.println();
   file.println("#ifdef HAVE_JIKES_NAMESPACE");
   file.println("} // Close namespace Jikes block");
   file.println("#endif");
   file.println();
 }
	public void WriteHeader(){
		out.println("\t\t"+Parser.StartingTag("ValidichroHeader"));
		out.println("\t\t\t"+Parser.Tag("Date",experiment_date));
		out.println("\t\t\t"+Parser.Tag("Generic",generic));
		//...
		out.println("\t\t"+Parser.EndingTag("ValidichroHeader"));
	}
  // jumper
  // jumper carries out the jump instruction for the conditional jumps
  public static void jumper(String op) {
    // JUMP1 read the high order half of the address into DR
    DR = readMemory(AR);
    PC++;
    AR++;
    out.println(
        op
            + "1 AR = "
            + ((int) 0xFFFF & AR)
            + " PC = "
            + ((int) 0xFFFF & PC)
            + " DR = "
            + ((int) 0xFF & DR));

    // JUMP2 save the contents of DR
    TR = DR;
    DR = readMemory(AR);
    PC++;
    out.println(
        op
            + "2 AR = "
            + ((int) 0xFFFF & AR)
            + " PC = "
            + ((int) 0xFFFF & PC)
            + " DR = "
            + ((int) 0xFF & DR)
            + " TR = "
            + ((int) 0xFF & TR));

    // JUMP3 form the address from TR and DR and place it in PC

    PC = (short) (((0xFF & TR) * 256) + (0xFF & DR));
    out.println(op + "3 PC = " + ((int) 0xFFFF & AR));
  }
Beispiel #11
0
  public void saveFile(File f) throws IOException {
    PrintStream ps = new PrintStream(new FileOutputStream(f));
    ps.print("ID");
    for (Column c : cols) {
      ps.print(String.format("\t%s", c.id));
    }
    ps.println();
    for (int i = 0; i < samples.size(); i++) {
      ps.print(samples.get(i));
      for (int j = 0; j < cols.size(); j++) {
        Float ff = cols.get(j).values.get(i);
        if (ff == null) {
          ps.print("\tnull");
        } else {
          ps.print(String.format("\t%.2f", ff));
        }
      }
      ps.println();

      if (i > 0) {
        if (i % 100 == 0) {
          System.out.print(".");
          System.out.flush();
        }
      }
    }
    System.out.println();
    ps.close();
  }
Beispiel #12
0
  /**
   * ********************************************************************** Prints the iniFile.
   *
   * @param ps The <code>PrintStream</code> to which to print.
   */
  public void printProps(PrintStream ps) {

    Enumeration se = getSectionList();

    if (se == null) {
      ps.println(errMsg);
    } else {

      while (se.hasMoreElements()) {

        String sname = (String) se.nextElement();

        setSection(sname);

        ps.println("[" + sname + "]");

        Enumeration pe = getPropList(sname);

        while (pe.hasMoreElements()) {

          String pair[] = (String[]) pe.nextElement();

          String prop = pair[0];

          String valu = getProperty(prop);

          ps.println("    \"" + prop + "\" = \"" + valu + "\"");
        }
      }
    }
  }
Beispiel #13
0
 protected int unknownArgument(String[] args, String arg, int argNum) {
   if (arg == "-t") {
     arg = args[++argNum];
     if (arg.equalsIgnoreCase("parse")) setTraceParse(true);
     else if (arg.equalsIgnoreCase("gen")) setTraceGen(true);
     else if (arg.equalsIgnoreCase("dot")) setTraceDot(true);
     else {
       if (!arg.equalsIgnoreCase("all"))
         --argNum; // unknown value, trace all, and rethink that option
       setTraceParse(true);
       setTraceGen(true);
       setTraceMisc(true);
       setTraceDot(true);
     }
   } else if (arg == "-version") {
     messageOut.println("schema2beans - " + Version.getVersion());
     System.exit(0);
   } else if (arg == "-xmlschema") setSchemaTypeNum(XML_SCHEMA);
   else if (arg == "-dtd") setSchemaTypeNum(DTD);
   else if (arg == "-premium") buyPremium();
   else if (arg == "-strict") useStrict();
   else if (arg == "-basebean") {
     setOutputType(OUTPUT_TRADITIONAL_BASEBEAN);
   } else if (arg == "-javabeans") setOutputType(OUTPUT_JAVABEANS);
   else if (arg == "-commoninterface") setGenerateCommonInterface(COMMON_BEAN);
   else if (arg == "-nocommoninterface") setGenerateCommonInterface(null);
   else {
     messageOut.println("Unknown argument: " + arg);
     messageOut.println("Use -help.");
     System.exit(1);
   }
   return argNum;
 }
  /**
   * Prints the given map with nice line breaks.
   *
   * @param out the stream to print to
   * @param key the key that maps to the map in some other map
   * @param map the map to print
   */
  public static synchronized void debugPrint(PrintStream out, Object key, Map map) {
    debugPrintIndent(out);
    out.println(key + " = ");

    debugPrintIndent(out);
    out.println("{");
    ++debugIndent;

    for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
      Map.Entry entry = (Map.Entry) iter.next();
      String childKey = (String) entry.getKey();
      Object childValue = entry.getValue();
      if (childValue instanceof Map) {
        verbosePrint(out, childKey, (Map) childValue);
      } else {
        debugPrintIndent(out);

        String typeName = (childValue != null) ? childValue.getClass().getName() : null;

        out.println(childKey + " = " + childValue + " class: " + typeName);
      }
    }
    --debugIndent;
    debugPrintIndent(out);
    out.println("}");
  }
  public void save(File f) throws IOException {
    PrintStream ps = new PrintStream(new FileOutputStream(f));
    String[] genes = genes();

    Vector<Map<String, Double>> maps = new Vector<Map<String, Double>>();
    for (int j = 0; j < coefs.size(); j++) {
      maps.add(coefs.get(j).geneValues(args.compare));
    }

    ps.print("gene");
    for (int i = 0; i < coefs.size(); i++) {
      ps.print(" " + keys.get(i));
    }
    ps.println();

    for (int i = 0; i < genes.length; i++) {
      ps.print(String.format("%s", genes[i]));

      for (int j = 0; j < coefs.size(); j++) {
        Map<String, Double> map = maps.get(j);
        Double value = map.containsKey(genes[i]) ? map.get(genes[i]) : null;

        ps.print(String.format(" %s", value != null ? String.format("%.2f", value) : "N/A"));
      }

      ps.println();
    }

    ps.println();
    ps.close();
  }
Beispiel #16
0
  @Override
  public boolean checkout(
      AbstractBuild build,
      Launcher launcher,
      FilePath workspace,
      BuildListener listener,
      File changelogFile)
      throws IOException, InterruptedException {

    long start = System.currentTimeMillis();
    PrintStream log = launcher.getListener().getLogger();
    log.println("FSSCM.checkout " + path + " to " + workspace);
    Boolean b = Boolean.TRUE;

    AllowDeleteList allowDeleteList = new AllowDeleteList(build.getProject().getRootDir());

    if (clearWorkspace) {
      log.println("FSSCM.clearWorkspace...");
      workspace.deleteRecursive();
    }

    // we will only delete a file if it is listed in the allowDeleteList
    // ie. we will only delete a file if it is copied by us
    if (allowDeleteList.fileExists()) {
      allowDeleteList.load();
    } else {
      // watch list save file doesn't exist
      // we will assuem all existing files are under watch
      // ie. everything can be deleted
      Set<String> existingFiles = workspace.act(new RemoteListDir());
      allowDeleteList.setList(existingFiles);
    }

    RemoteFolderDiff.CheckOut callable = new RemoteFolderDiff.CheckOut();
    setupRemoteFolderDiff(callable, build.getProject(), allowDeleteList.getList());
    List<FolderDiff.Entry> list = workspace.act(callable);

    // maintain the watch list
    for (FolderDiff.Entry entry : list) {
      if (FolderDiff.Entry.Type.DELETED.equals(entry.getType())) {
        allowDeleteList.remove(entry.getFilename());
      } else {
        // added or modified
        allowDeleteList.add(entry.getFilename());
      }
    }
    allowDeleteList.save();

    // raw log
    String str = callable.getLog();
    if (str.length() > 0) log.println(str);

    ChangelogSet.XMLSerializer handler = new ChangelogSet.XMLSerializer();
    ChangelogSet changeLogSet = new ChangelogSet(build, list);
    handler.save(changeLogSet, changelogFile);

    log.println("FSSCM.check completed in " + formatDurration(System.currentTimeMillis() - start));
    return b;
  }
Beispiel #17
0
 /**
  * Prints the properties of this device manager and all of the devices found on the bus to the
  * specified print stream. Mainly useful for diagnostic purposes.
  *
  * @param stream the print stream where properties will be printed.
  * @return The print stream.
  */
 public PrintStream print(PrintStream stream) {
   if (!isOpen()) throw new OperationFailedException(MESSAGE_NOT_OPEN);
   if (deviceList.size() > 0) {
     stream.println("ACCES devices found:");
     for (USBDevice device : deviceList) device.print(stream);
   } else stream.println("No ACCES devices found");
   return stream;
 } // print()
	public void WriteExported(){
		out.println(Parser.getFileHeader());
		out.println("\t"+Parser.StartingTag("ValidichroData"));
		WriteHeader();
		WriteBody();
		WriteUnparsed();
		out.println("\t"+Parser.EndingTag("ValidichroData"));
	}
 public static void xmvac() {
   out.println("xmvac instruction");
   // XMVAC1 moves AC to R
   // clear out the bottom short of R
   R -= (0xFFFF & R);
   // add in the bottom short of AC
   R += (0xFFFF & AC);
   out.println("xmvac1 R = " + R);
 }
 // movr
 // movr puts the value in the R register in the accumulator
 public static void movr() {
   out.println("movr instruction");
   // MOVR1 puts the value in the R register into the accumulator
   // clear out the bottom byte of R
   AC -= (0xFF & AC);
   // add in the bottom byte of AC
   AC += (0xFF & R);
   out.println("movr1 AC = " + (byte) (0xFF & AC));
 }
 public static void xmovr() {
   out.println("xmovr instruction");
   // XMVAC1 moves R to AC
   // clear out the bottom short of AC
   AC -= (0xFFFF & AC);
   // add in the bottom short of R
   AC += (0xFFFF & R);
   out.println("xmovr1 AC = " + AC);
 }
  public void print(String prefix, PrintStream out) {
    super.print(prefix, out);

    out.println(prefix + "{");
    String orgPrefix = prefix;
    prefix += "   ";
    for (int i = 0; i < list.size(); i++) list.get(i).print(prefix, out);
    out.println(orgPrefix + "}");
  }
  public static void createFileOfRandomIntegers(String outputFileName) throws IOException {

    PrintStream printstream;
    printstream = new PrintStream(outputFileName);
    int numberOfIntegers = (int) (Math.random() * 100) % 10 + 1;
    printstream.println(numberOfIntegers);
    for (int i = 0; i < numberOfIntegers; i++)
      printstream.println((int) (Math.random() * 1000) % 100 + 1);
    printstream.close();
  }
 public void print(String prefix, PrintStream out) {
   super.print(prefix, out);
   out.println(prefix + "{");
   String orgPrefix = prefix;
   prefix += "   ";
   for (Tag tag : tags.values()) {
     tag.print(prefix, out);
   }
   out.println(orgPrefix + "}");
 }
	public void WriteUnparsed(){
		//@ToDo : Make this proper java!
		out.println("           <ValidichroUnparsed>");
		int s = unparsed_lines.size();
		for(int i=0;i<s;i++){
			String line=(String)unparsed_lines.get(i);
			out.println("           	<ValidichroUnparsedLine>"+line+"</ValidichroUnparsedLine>");
		}
		out.println("           </ValidichroUnparsed>");
	}
	public void WriteBody(){
		//@ToDo : Make this proper java!
		//@ToDo Important:  Add missing elements and check existing ones
		//	-	Update:, now refers to values as Unknown1,Uknown2... It's just unknown to me, can't remember what these values represent!
		out.println("\t\t"+Parser.StartingTag("ValidichroBody"));
		for(String line :spectral_table){
			out.println("\t\t\t"+Parser.Tag("SpectralEntry",line));
		}
		out.println("\t\t"+Parser.EndingTag("ValidichroBody"));
	}
 /**
  * Read a string from the command line
  *
  * @return a string
  */
 public static String readWord() {
   scanTo(tokenizer.TT_WORD);
   if (tokenizer.sval != null) {
     if (outFile != null) outFile.println("" + tokenizer.sval);
     return (tokenizer.sval);
   } else {
     if (outFile != null) outFile.println("" + ((char) tokenizer.ttype));
     return ("" + ((char) tokenizer.ttype));
   }
 }
  // mvac
  // mvac places the value in AC into the R register
  public static void mvac() {
    out.println("mvac instruction");
    // MVAC1 put value in AC into the R register

    // clear out the bottom byte of R
    R -= (0xFF & R);
    // add in the bottom byte of AC
    R += 0xFF & AC;
    out.println("mvac1 R = " + (byte) (0xFF & R));
  }
 public void save(PrintStream stream) {
   saved = true;
   stream.println("<?xml version=\"1.0\"?>");
   stream.println("<scale>");
   stream.println("  <name>" + nameTF.getText() + "</name>");
   for (Enumeration en = sp.notes.elements(); en.hasMoreElements(); ) {
     ScalePanel.Notik cur = (ScalePanel.Notik) en.nextElement();
     stream.println("  <note>" + cur.n + "</note>");
   }
   stream.println("</scale>");
 }
Beispiel #30
0
 public void writeMetadata(final PrintStream s) {
   s.print("  Evaluation type: ");
   for (final Eval e : evals) s.print(e.getEvalName() + " ");
   s.println();
   s.println("  Test files:");
   for (final String f : corpusFiles) s.println("    " + f);
   if (filterLength > 0) s.println("  Filter test files by len: " + filterLength);
   //    if (numSent > 0)
   //      s.println("  Num test sentences: " + numSent);
   s.println("  Test file type: " + testFileType);
 }