public void run() {
    runs = true;

    // notification about starting the input process
    stream.postEvent(new ServerEvent(this, stream, ServerEvent.INPUT_START));

    changeState(new HeaderDetectionState(this, stream));

    byte[] buffer = new byte[65535];
    int offset = 0;
    int length = 0;
    while (runs && stream.running()) {

      try {

        // starting time of the transfer
        long transferStart = new Date().getTime();

        // reading data
        int red = input.read(buffer, offset, buffer.length - offset);

        // notification about the transfer
        stream.postEvent(
            new TransferEvent(
                this,
                stream,
                TransferEvent.STREAM_INPUT,
                red,
                new Date().getTime() - transferStart));

        if (red == -1) runs = false;
        length += red;

        int newOffset = currentState.processData(buffer, 0, length);
        if (newOffset < offset + length) {
          length = length - newOffset;
          System.arraycopy(buffer, newOffset, buffer, 0, length);
          offset = length;
        } else {
          length = 0;
          offset = 0;
        }

      } catch (SocketTimeoutException e) {
        continue;
      } catch (Exception e) {
        e.printStackTrace();
        runs = false;
      }
    }

    try {
      input.close();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    // notification about ending the input process
    stream.postEvent(new ServerEvent(this, stream, ServerEvent.INPUT_STOP));
  }
Beispiel #2
0
 public final void method190(
     int i, Class11 aclass11[], int j, WorldController worldController, byte abyte0[]) {
   label0:
   {
     Stream stream = new Stream(abyte0);
     int l = -1;
     do {
       int i1 = stream.method422();
       if (i1 == 0) break label0;
       l += i1;
       int j1 = 0;
       do {
         int k1 = stream.method422();
         if (k1 == 0) break;
         j1 += k1 - 1;
         int l1 = j1 & 0x3f;
         int i2 = j1 >> 6 & 0x3f;
         int j2 = j1 >> 12;
         int k2 = stream.readUnsignedByte();
         int l2 = k2 >> 2;
         int i3 = k2 & 3;
         int j3 = i2 + i;
         int k3 = l1 + j;
         if (j3 > 0 && k3 > 0 && j3 < 103 && k3 < 103) {
           int l3 = j2;
           if ((aByteArrayArrayArray149[1][j3][k3] & 2) == 2) l3--;
           Class11 class11 = null;
           if (l3 >= 0) class11 = aclass11[l3];
           method175(k3, worldController, class11, l2, j2, j3, l, i3);
         }
       } while (true);
     } while (true);
   }
 }
Beispiel #3
0
 private Hashtable<String, String> getJarManifestAttributes(String path) {
   Hashtable<String, String> h = new Hashtable<String, String>();
   JarInputStream jis = null;
   try {
     cp.appendln(Color.black, "Looking for " + path);
     InputStream is = getClass().getResourceAsStream(path);
     if (is == null) {
       if (!path.endsWith("/MIRC.jar")) {
         cp.appendln(Color.red, "...could not find it.");
       } else {
         cp.appendln(
             Color.black,
             "...could not find it. [OK, this is a " + programName + " installation]");
       }
       return null;
     }
     jis = new JarInputStream(is);
     Manifest manifest = jis.getManifest();
     h = getManifestAttributes(manifest);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   if (jis != null) {
     try {
       jis.close();
     } catch (Exception ignore) {
     }
   }
   return h;
 }
  Stream<Number> test() {
    Stream<Number> numberStream = null;
    Stream<Number> integerStream1 = numberStream.map(this::toInt);
    Stream<Number> integerStream2 = numberStream.map(num -> toInt(num));

    return numberStream.map(this::toInt);
  }
  /** Initializes the SDK and the controller. */
  public boolean initializeTwitch() {
    if (m_SdkInitialized) {
      return false;
    }

    String dllPath = m_DllPath;
    if (dllPath == "") {
      dllPath = "./";
    }

    m_Stream.setStreamCallbacks(this);

    ErrorCode err = m_Stream.initialize(m_ClientId, VideoEncoder.TTV_VID_ENC_DEFAULT, dllPath);
    if (!checkError(err)) {
      m_Stream.setStreamCallbacks(null);
      return false;
    }

    err = m_Stream.setTraceLevel(MessageLevel.TTV_ML_ERROR);
    if (!checkError(err)) {
      m_Stream.setStreamCallbacks(null);
      return false;
    }

    if (ErrorCode.succeeded(err)) {
      m_SdkInitialized = true;
      setBroadcastState(BroadcastState.Initialized);
      return true;
    }

    return false;
  }
Beispiel #6
0
 /**
  * Fills the content of this object with information retrived from a stream.
  *
  * @param the stream used in the serialization process.
  */
 public void unmarshal(Stream b) throws MarshalException {
   this.initialize();
   for (int i = b.readInt(); i > 0; i--) {
     RemoteReference r = (RemoteReference) b.readObject();
     this.attach(r);
   }
 }
Beispiel #7
0
  public static void update() {
    Statistics.colonyReset();

    for (Mouse mouse : mice) {
      mouse.update();
      if (!mouse.isAlive()) deadMice.add(mouse);

      Statistics.colonyInclude(mouse);
    }

    Statistics.colonyReady();

    while (!deadMice.isEmpty()) {
      Mouse deadMouse = deadMice.remove();

      mice.remove(deadMouse);
      Stream.history("Colony Size: " + mice.size());
      MouseSim.getWorld().getWorldNode(deadMouse.getPosition()).remove(deadMouse);

      if (mice.size() == 1) {
        Stream.update(mice.get(0) + " is the last mouse alive! x_x");
      }
    }

    while (!bornMice.isEmpty()) {
      Mouse bornMouse = bornMice.remove();
      mice.add(bornMouse);
      Stream.history("Colony Size: " + mice.size());
    }

    if (mice.isEmpty()) {
      MouseSim.endGame("all the mice have died.");
    }
  }
Beispiel #8
0
 private void fixConfigSchema() {
   File configFile;
   File ctpDir = new File(directory, "CTP");
   if (ctpDir.exists()) configFile = new File(ctpDir, "config.xml");
   else configFile = new File(directory, "config.xml");
   if (configFile.exists()) {
     try {
       Document doc = getDocument(configFile);
       Element root = doc.getDocumentElement();
       Element server = getFirstNamedChild(root, "Server");
       moveAttributes(server, sslAttrs, "SSL");
       moveAttributes(server, proxyAttrs, "ProxyServer");
       moveAttributes(server, ldapAttrs, "LDAP");
       if (programName.equals("ISN")) fixRSNAROOT(server);
       if (isMIRC(root)) fixFileServiceAnonymizerID(root);
       setFileText(configFile, toString(doc));
     } catch (Exception ex) {
       cp.appendln(Color.red, "\nUnable to convert the config file schema.");
       cp.appendln(Color.black, "");
     }
   } else {
     cp.appendln(Color.red, "\nUnable to find the config file to check the schema.");
     cp.appendln(Color.black, "");
   }
 }
Beispiel #9
0
 public boolean isAutoclose() {
   boolean autoclose = true;
   Stream myMain, myPipe;
   if ((myMain = mainStream) != null) autoclose &= myMain.isAutoclose();
   if ((myPipe = pipeStream) != null) autoclose &= myPipe.isAutoclose();
   return autoclose;
 }
Beispiel #10
0
  public boolean shutdown(int port, boolean ssl) {
    try {
      String protocol = "http" + (ssl ? "s" : "");
      URL url = new URL(protocol, "127.0.0.1", port, "shutdown");
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
      conn.setRequestProperty("servicemanager", "shutdown");
      conn.connect();

      StringBuffer sb = new StringBuffer();
      BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
      int n;
      char[] cbuf = new char[1024];
      while ((n = br.read(cbuf, 0, cbuf.length)) != -1) sb.append(cbuf, 0, n);
      br.close();
      String message = sb.toString().replace("<br>", "\n");
      if (message.contains("Goodbye")) {
        cp.appendln("Shutting down the server:");
        String[] lines = message.split("\n");
        for (String line : lines) {
          cp.append("...");
          cp.appendln(line);
        }
        return true;
      }
    } catch (Exception ex) {
    }
    cp.appendln("Unable to shutdown CTP");
    return false;
  }
Beispiel #11
0
 public StreamLoader(byte abyte0[]) {
   Stream stream = new Stream(abyte0);
   int i = stream.read3Bytes();
   int j = stream.read3Bytes();
   if (j != i) {
     byte abyte1[] = new byte[i];
     Class13.method225(abyte1, i, abyte0, j, 6);
     aByteArray726 = abyte1;
     stream = new Stream(aByteArray726);
     aBoolean732 = true;
   } else {
     aByteArray726 = abyte0;
     aBoolean732 = false;
   }
   dataSize = stream.readUnsignedWord();
   anIntArray728 = new int[dataSize];
   anIntArray729 = new int[dataSize];
   anIntArray730 = new int[dataSize];
   anIntArray731 = new int[dataSize];
   int k = stream.currentOffset + dataSize * 10;
   for (int l = 0; l < dataSize; l++) {
     anIntArray728[l] = stream.readDWord();
     anIntArray729[l] = stream.read3Bytes();
     anIntArray730[l] = stream.read3Bytes();
     anIntArray731[l] = k;
     k += anIntArray730[l];
   }
 }
Beispiel #12
0
 public static void main(String[] args) {
   Personne[] tab = {
     new Personne("thibault", "Rougier", 2001),
     new Personne("thomas", "Niesseron", 1987),
     new Personne("thifaine", "Mitenne", 1959),
     new Personne("maxime", "Forest", 1995),
     new Personne("jules", "Forest", 1995)
   };
   System.out.println("--- Nes apres 1985 : ");
   Stream.of(tab)
       .filter(pp -> pp.getAnnee() > 1985)
       .forEach(pp -> System.out.print(pp.getPrenom() + ", "));
   System.out.println("\n--- Nes avant 2000 :");
   long nombre =
       Stream.of(tab)
           .filter(pp -> pp.getAnnee() < 2000)
           .sorted(Comparator.comparing(Personne::getNom))
           .peek(pp -> System.out.print(pp.getNom() + " "))
           .count();
   System.out.println("\n       Ils sont " + nombre);
   System.out.println("--- Tous tries sur nom + prenom : ");
   Stream.of(tab)
       .sorted(Comparator.comparing(pp -> pp.getNom() + pp.getPrenom()))
       .forEach(pp -> System.out.print("(" + pp.getNom() + ", " + pp.getPrenom() + ") "));
 }
Beispiel #13
0
 /**
  * Provides a stream of the elements of the tree at each level, in level order.
  *
  * @return The elements of the tree at each level.
  */
 public Stream<Stream<A>> levels() {
   final F<Stream<Tree<A>>, Stream<Tree<A>>> flatSubForests =
       Stream.<Tree<A>, Tree<A>>bind_()
           .f(compose(P1.<Stream<Tree<A>>>__1(), Tree.<A>subForest_()));
   final F<Stream<Tree<A>>, Stream<A>> roots = Stream.<Tree<A>, A>map_().f(Tree.<A>root_());
   return iterateWhile(flatSubForests, Stream.<Tree<A>>isNotEmpty_(), single(this)).map(roots);
 }
 public void method2038(int arg0, Stream arg1, boolean arg2) {
   anInt6372++;
   if (arg0 != 1) {
     if (arg0 == 2) anInt6374 = arg1.readUnsignedInt(-2);
     else if ((arg0 ^ 0xffffffff) == -6) aString6377 = arg1.readString(false);
   } else aChar6378 = Class214.method2782(60, arg1.readSignedByte((byte) 127));
   if (arg2 != false) aString6377 = null;
 }
  private static void method494(char ac[][], Stream stream) {
    for (int j = 0; j < ac.length; j++) {
      char ac1[] = new char[stream.readUnsignedByte()];
      for (int k = 0; k < ac1.length; k++) ac1[k] = (char) stream.readUnsignedByte();

      ac[j] = ac1;
    }
  }
Beispiel #16
0
 /**
  * Calculates the minimum of this elements according to their natural order.
  *
  * @return {@code Some(minimum)} of this elements or {@code None} if this is empty or this
  *     elements are not comparable
  */
 @SuppressWarnings("unchecked")
 default Option<T> min() {
   final Stream<T> stream = Stream.ofAll(iterator());
   if (isEmpty() || !(stream.head() instanceof Comparable)) {
     return None.instance();
   } else {
     return stream.minBy((o1, o2) -> ((Comparable<T>) o1).compareTo(o2));
   }
 }
Beispiel #17
0
 @SuppressWarnings("unchecked")
 @Override
 default Tuple2<Seq<T>, Seq<T>> span(Predicate<? super T> predicate) {
   Objects.requireNonNull(predicate, "predicate is null");
   if (isEmpty()) {
     return Tuple.of(Stream.empty(), Stream.empty());
   } else {
     return (Tuple2<Seq<T>, Seq<T>>) traverse().span(predicate);
   }
 }
 @Test
 public void shouldConvertToStream() {
   final Value<Integer> value = of(1, 2, 3);
   final Stream<Integer> stream = value.toStream();
   if (value.isSingleValued()) {
     assertThat(stream).isEqualTo(Stream.of(1));
   } else {
     assertThat(stream).isEqualTo(Stream.of(1, 2, 3));
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.show);

    super.type = API.TYPE_THREAD;
    super.thread = getIntent().getStringExtra("thread");
    super.init();
  }
Beispiel #20
0
 /**
  * Applies a stream of comonadic functions to this product, returning a stream of values.
  *
  * @param fs A stream of functions to apply to this product.
  * @return A stream of the results of applying the given stream of functions to this product.
  */
 public <C> Stream<C> sequenceW(final Stream<F<P2<A, B>, C>> fs) {
   return fs.isEmpty()
       ? Stream.<C>nil()
       : Stream.cons(
           fs.head().f(this),
           new P1<Stream<C>>() {
             public Stream<C> _1() {
               return sequenceW(fs.tail()._1());
             }
           });
 }
Beispiel #21
0
 static <T> Stream<T> levelOrder(Tree<T> tree) {
   Stream<T> result = Stream.empty();
   final java.util.Queue<Tree<T>> queue = new java.util.LinkedList<>();
   queue.add(tree);
   while (!queue.isEmpty()) {
     final Tree<T> next = queue.remove();
     result = result.prepend(next.getValue());
     queue.addAll(next.getChildren().toJavaList());
   }
   return result.reverse();
 }
Beispiel #22
0
 /**
  * Verifica se o caracter {@code stream} está duplicado.
  *
  * @param stream - {@link Stream} a ser verificada.
  * @param atualChar - Caracter que sera verificado.
  * @return - Retorna {@code true} se for duplicado e {@code false} se nao for.
  * @throws CloneNotSupportedException
  */
 private static boolean isDublicatedChar(Stream stream, char atualChar)
     throws CloneNotSupportedException {
   Stream streamAux = stream.clone();
   int duplicateTimes = 0;
   while (streamAux.hasNext()) {
     char searchChar = streamAux.getNext();
     if (atualChar == searchChar && ++duplicateTimes > 1) {
       return true;
     }
   }
   return false;
 }
Beispiel #23
0
 static <T> Stream<T> inOrder(Tree<T> tree) {
   if (tree.isLeaf()) {
     return Stream.of(tree.getValue());
   } else {
     final List<Node<T>> children = tree.getChildren();
     return children
         .tail()
         .foldLeft(Stream.<T>empty(), (acc, child) -> acc.appendAll(inOrder(child)))
         .prepend(tree.getValue())
         .prependAll(inOrder(children.head()));
   }
 }
  private static void readTldList(Stream stream) {
    int i = stream.readDWord();
    aCharArrayArray624 = new char[i][];
    anIntArray625 = new int[i];
    for (int j = 0; j < i; j++) {
      anIntArray625[j] = stream.readUnsignedByte();
      char ac[] = new char[stream.readUnsignedByte()];
      for (int k = 0; k < ac.length; k++) ac[k] = (char) stream.readUnsignedByte();

      aCharArrayArray624[j] = ac;
    }
  }
Beispiel #25
0
  public static void main(String[] args) {
    // check args
    Stream.of(args).forEach(System.out::println);

    // check .
    Stream.of(new File(".").list()).forEach(System.out::println);

    // check external libs
    Client client = ClientBuilder.newClient();
    String response = client.target("https://api.github.com/zen").request().get(String.class);
    System.out.println(response);
  }
Beispiel #26
0
 public static Class13_Sub1 method1598(int i, Stream class68_sub14) {
   if (i != -20084) aRSString_2317 = null;
   anInt2301++;
   return new Class13_Sub1(
       class68_sub14.method957(i + -2405),
       class68_sub14.method957(i + -2405),
       class68_sub14.method957(-22489),
       class68_sub14.method957(-22489),
       class68_sub14.method921((byte) -58),
       class68_sub14.method921((byte) -124),
       class68_sub14.readUnsignedByte(-6677));
 }
Beispiel #27
0
  public static ArrayList<Variable> allVisibleVariables(EObject container) {
    ArrayList<Variable> result = new ArrayList<Variable>();

    if (container instanceof LocalVariable) {
      if (container.eContainer() instanceof Stream) {
        return allVisibleVariables(container.eContainer());
      }
    }

    // Add the variables of the block if we are in a block
    ActionBlock b = findContainingActionBlock(container);
    if (b != null) {
      for (Action a : b.getActions()) {
        if (a == container || a.eContents().contains(container))
          continue; // ignore variables defined after the current statement
        if (a instanceof Variable) result.add((Variable) a);
      }

      result.addAll(allVisibleVariables(b.eContainer()));

      return result;
    }

    // Add the variables of the state if we are in a state
    State s = findContainingState(container);
    if (s != null) {
      result.addAll(allProperties(s));
      return result;
    }

    // Add parameters of the function if we are in a function
    Function f = findContainingFunction(container);
    if (f != null) {
      result.addAll(f.getParameters());
      result.addAll(allVisibleVariables(f.eContainer()));
    }

    Stream stream = findContainingStream(container);
    if (stream != null) {
      result.addAll(stream.getSelection());
    }

    // Only the variables of the thing if we are in a thing:
    Thing t = findContainingThing(container);
    if (t != null) {
      // Properties from the thing
      result.addAll(allProperties(t));
      return result;
    }

    return result;
  }
  public static void main(String... args) {

    /*
    -------------------------------------------------------------------------
    From obj to ...
    -------------------------------------------------------------------------
    */
    Stream<String> streamOfStrings = Stream.of("un", "deux", "trois");
    Function<String, StringBuilder> function = StringBuilder::new;
    streamOfStrings.map(function) /*.forEach(System.out::println)*/;
    streamOfStrings = Stream.of("un", "deux", "trois");
    ToIntFunction<String> toIntFunction = String::length;
    IntStream streamOfInts = streamOfStrings.mapToInt(toIntFunction);
    streamOfStrings = Stream.of("un", "deux", "trois");
    ToDoubleFunction<String> toDoubleFunction = String::length;
    DoubleStream streamOfDoubles = streamOfStrings.mapToDouble(toDoubleFunction);
    streamOfStrings = Stream.of("un", "deux", "trois");
    ToLongFunction<String> toLongFunction = String::length;
    LongStream streamOfLongs = streamOfStrings.mapToLong(toLongFunction);

    /*
    -------------------------------------------------------------------------
    From int to ...
    -------------------------------------------------------------------------
    */
    IntUnaryOperator plusplus = i -> i++;
    IntStream.of(1, 2, 3).map(plusplus)
    /*.forEach(x->System.out.println(x))*/ ;
    IntFunction<String> intFunction = i -> "" + i;
    IntStream.of(1, 2, 3).mapToObj(intFunction)
    /*.forEach(System.out::println)*/ ;
    IntToDoubleFunction itdf = i -> i;
    IntStream.of(1, 2, 3).mapToDouble(itdf)
    /*.forEach(System.out::println)*/ ;
    IntToLongFunction itlf = i -> i;
    IntStream.of(1, 2, 3).mapToLong(itlf)
    /*.forEach(System.out::println)*/ ;

    /*
    -------------------------------------------------------------------------
    From long to ...
    -------------------------------------------------------------------------
    */
    LongUnaryOperator times = l -> l * l;
    LongStream.of(1L, 2L, 3L).map(times)
    /*.forEach(System.out::println)*/ ;
    LongFunction<String> lf = l -> "toto";
    LongStream.of(1L, 2L, 3L).mapToObj(lf);

    /*
    -------------------------------------------------------------------------
    From double to ...
    -------------------------------------------------------------------------
    */
    DoubleToIntFunction dtif = d -> (int) d;
    DoubleStream.of(1.3, 1.5, 1.6).mapToInt(dtif).forEach(System.out::println);
  }
Beispiel #29
0
 /**
  * Procura o primeiro caracter do fluxo do objeto {@code stream} que não se repete.
  *
  * @param stream - {@link Stream} a ser verificada.
  * @return - Primeiro caracter. caracter que não se repete.
  */
 public static char findFirstChar(Stream stream) {
   try {
     while (stream.hasNext()) {
       char atualChar = stream.getNext();
       if (!isDublicatedChar(stream, atualChar)) {
         return atualChar;
       }
     }
   } catch (Throwable throwable) {
     throw new StreamException(throwable);
   }
   throw new StreamException("Single char not found.");
 }
Beispiel #30
0
 /** The remote invocation occurs only if the cache misses. */
 public Stream invoke(RemoteCall c, RemoteReference ref) throws NetworkException {
   Stream args = ((RmeRemoteCall) c).getArguments();
   if (table.containsKey(args)) {
     Stream returnValue = OrbAccessor.getStream();
     returnValue.fill((RmeStream) table.get(args));
     return returnValue;
   } else {
     Stream returnValue = super.invoker.invoke(c, ref);
     Stream backupValue = OrbAccessor.getStream();
     backupValue.fill(returnValue);
     table.put(args, backupValue);
     return returnValue;
   }
 }