Android Open Source - android-chess c






From Project

Back to project page android-chess.

License

The source code is released under:

MIT License

If you think the Android project android-chess listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package jwtc.android.timeseal.streams;
//from w  w  w. j  av  a2s.c o  m
import java.io.IOException;
import java.io.InterruptedIOException;

public class c
{
  private static final int jdField_new = 2048;
  private final a jdField_else;
  private final b jdField_try;
  private volatile int jdField_do = 0;
  private byte[] jdField_for;
  private final boolean jdField_byte;
  private int jdField_goto = 0;
  private int jdField_char = 0;
  private boolean jdField_int = false;
  private boolean jdField_if = false;
  private Object a = new String("Write Lock for PipedStreams");
  private Object jdField_case = new String("Read Lock for PipedStream");

  public void jdField_if(int paramInt)
  {
    synchronized (this.jdField_case)
    {
      this.jdField_do = paramInt;
    }
  }

  public int jdField_do()
  {
    return this.jdField_do;
  }

  public a jdField_if()
  {
    return this.jdField_else;
  }

  public b jdField_byte()
  {
    return this.jdField_try;
  }

  synchronized int jdField_case()
  {
    if (this.jdField_if)
      return 0;
    return jdField_int();
  }

  private final int jdField_int()
  {
    if (this.jdField_char >= this.jdField_goto)
      return this.jdField_char - this.jdField_goto;
    return this.jdField_char + this.jdField_for.length - this.jdField_goto;
  }

  private final int a()
  {
    return this.jdField_for.length - jdField_int() - 1;
  }

  private final void jdField_do(int paramInt)
  {
    int i = paramInt < this.jdField_for.length ? this.jdField_for.length : paramInt;
    byte[] arrayOfByte = new byte[this.jdField_for.length + i];
    System.arraycopy(this.jdField_for, 0, arrayOfByte, 0, this.jdField_for.length);
    this.jdField_for = arrayOfByte;
  }

  synchronized void a(int paramInt)
    throws IOException
  {
    synchronized (this.a)
    {
      if ((this.jdField_if) || (this.jdField_int))
        throw new IOException("Stream closed");
      while (a() == 0)
        if (this.jdField_byte)
          jdField_do(1);
        else
          try
          {
            wait();
          }
          catch (InterruptedException localInterruptedException)
          {
            throw new InterruptedIOException();
          }
      if ((this.jdField_if) || (this.jdField_int))
        throw new IOException("Stream closed");
      this.jdField_for[(this.jdField_char++)] = ((byte)(paramInt & 0xFF));
      if (this.jdField_char == this.jdField_for.length)
        this.jdField_char = 0;
      notifyAll();
    }
  }

  synchronized void a(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    synchronized (this.a)
    {
      if ((this.jdField_if) || (this.jdField_int))
        throw new IOException("Stream closed");
      if ((this.jdField_byte) && (paramInt2 > a()))
        jdField_do(paramInt2 - a());
      while (paramInt2 > 0)
      {
        while (a() == 0)
          try
          {
            wait();
          }
          catch (InterruptedException localInterruptedException)
          {
            throw new InterruptedIOException();
          }
        int i = a();
        int j = paramInt2 > i ? i : paramInt2;
        int k = this.jdField_for.length - this.jdField_char >= j ? j : this.jdField_for.length - this.jdField_char;
        int m = j - k > 0 ? j - k : 0;
        System.arraycopy(paramArrayOfByte, paramInt1, this.jdField_for, this.jdField_char, k);
        System.arraycopy(paramArrayOfByte, paramInt1 + k, this.jdField_for, 0, m);
        paramInt1 += j;
        paramInt2 -= j;
        this.jdField_char = ((this.jdField_char + j) % this.jdField_for.length);
        notifyAll();
      }
    }
  }

  synchronized int jdField_for()
    throws IOException
  {
    synchronized (this.jdField_case)
    {
      if (this.jdField_if)
        throw new IOException("Stream closed");
      long l1 = System.currentTimeMillis();
      while (jdField_case() == 0)
      {
        if (this.jdField_int)
          return -1;
        long l2 = System.currentTimeMillis();
        if ((this.jdField_do != 0) && (l2 - l1 >= this.jdField_do))
          throw new InterruptedIOException();
        try
        {
          if (this.jdField_do == 0)
            wait();
          else
            wait(this.jdField_do + l2 - l1);
        }
        catch (InterruptedException localInterruptedException)
        {
          throw new InterruptedIOException();
        }
        if (this.jdField_if)
          throw new IOException("Stream closed");
      }
      int i = this.jdField_for[(this.jdField_goto++)];
      if (this.jdField_goto == this.jdField_for.length)
        this.jdField_goto = 0;
      notifyAll();
      return i < 0 ? i + 256 : i;
    }
  }

  synchronized int jdField_if(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    synchronized (this.jdField_case)
    {
      if (this.jdField_if)
        throw new IOException("Stream closed");
      long l1 = System.currentTimeMillis();
      while (jdField_case() == 0)
      {
        if (this.jdField_int)
          return -1;
        long l2 = System.currentTimeMillis();
        if ((this.jdField_do != 0) && (l2 - l1 >= this.jdField_do))
          throw new InterruptedIOException();
        try
        {
          if (this.jdField_do == 0)
            wait();
          else
            wait(this.jdField_do + l2 - l1);
        }
        catch (InterruptedException localInterruptedException)
        {
          throw new InterruptedIOException();
        }
        if (this.jdField_if)
          throw new IOException("Stream closed");
      }
      int i = jdField_case();
      int j = paramInt2 > i ? i : paramInt2;
      int k = this.jdField_for.length - this.jdField_goto > j ? j : this.jdField_for.length - this.jdField_goto;
      int m = j - k > 0 ? j - k : 0;
      System.arraycopy(this.jdField_for, this.jdField_goto, paramArrayOfByte, paramInt1, k);
      System.arraycopy(this.jdField_for, 0, paramArrayOfByte, paramInt1 + k, m);
      this.jdField_goto = ((this.jdField_goto + j) % this.jdField_for.length);
      notifyAll();
      return j;
    }
  }

  synchronized void jdField_try()
  {
    if (this.jdField_int)
      throw new IllegalStateException("Already closed");
    this.jdField_int = true;
    notifyAll();
  }

  synchronized void jdField_new()
  {
    if (this.jdField_if)
      throw new IllegalStateException("Already closed");
    this.jdField_if = true;
    notifyAll();
  }

  public c()
  {
    this(2048, false);
  }

  public c(int paramInt)
  {
    this(paramInt, false);
  }

  public c(boolean paramBoolean)
  {
    this(2048, paramBoolean);
  }

  public c(int paramInt, boolean paramBoolean)
  {
    if (paramInt <= 0)
      throw new IllegalArgumentException("The buffer size must be a positive integer");
    this.jdField_else = new a(this);
    this.jdField_try = new b(this);
    this.jdField_byte = paramBoolean;
    this.jdField_for = new byte[paramInt];
  }
}




Java Source Code List

jwtc.android.chess.ChessFieldView.java
jwtc.android.chess.ChessImageView.java
jwtc.android.chess.ChessPreferences.java
jwtc.android.chess.ChessViewBase.java
jwtc.android.chess.ChessView.java
jwtc.android.chess.GamesListView.java
jwtc.android.chess.HtmlActivity.java
jwtc.android.chess.ImageCacheObject.java
jwtc.android.chess.MyBaseActivity.java
jwtc.android.chess.MyPGNProvider.java
jwtc.android.chess.PGNView.java
jwtc.android.chess.SaveGameDlg.java
jwtc.android.chess.UI.java
jwtc.android.chess.convergence.Connection.java
jwtc.android.chess.convergence.ConvergenceActivity.java
jwtc.android.chess.convergence.RestServer.java
jwtc.android.chess.iconifiedlist.IconifiedTextListAdapter.java
jwtc.android.chess.iconifiedlist.IconifiedTextView.java
jwtc.android.chess.iconifiedlist.IconifiedText.java
jwtc.android.chess.ics.CustomCommands.java
jwtc.android.chess.ics.ICSChatDlg.java
jwtc.android.chess.ics.ICSChessView.java
jwtc.android.chess.ics.ICSClient.java
jwtc.android.chess.ics.ICSConfirmDlg.java
jwtc.android.chess.ics.ICSMatchDlg.java
jwtc.android.chess.ics.TelnetSocket.java
jwtc.android.chess.ics.TimesealInputStream.java
jwtc.android.chess.ics.TimesealOutputStream.java
jwtc.android.chess.ics.TimesealPipe.java
jwtc.android.chess.ics.TimesealingSocket.java
jwtc.android.chess.puzzle.ChessViewPractice.java
jwtc.android.chess.puzzle.ChessViewPuzzle.java
jwtc.android.chess.puzzle.MyPuzzleProvider.java
jwtc.android.chess.puzzle.practice.java
jwtc.android.chess.puzzle.puzzle.java
jwtc.android.chess.tools.FileListView.java
jwtc.android.chess.tools.PGNProcessor.java
jwtc.android.chess.tools.importactivity.java
jwtc.android.chess.tools.pgntool.java
jwtc.android.chess.main.java
jwtc.android.chess.options.java
jwtc.android.chess.setup.java
jwtc.android.chess.start.java
jwtc.android.timeseal.TimesealingSocket.java
jwtc.android.timeseal.streams.a.java
jwtc.android.timeseal.streams.b.java
jwtc.android.timeseal.streams.c.java
jwtc.chess.ChessPuzzleProvider.java
jwtc.chess.GameControl.java
jwtc.chess.JNI.java
jwtc.chess.Move.java
jwtc.chess.PGNColumns.java
jwtc.chess.PGNEntry.java
jwtc.chess.PGNProvider.java
jwtc.chess.Pos.java
jwtc.chess.Valuation.java
jwtc.chess.algorithm.SearchAlgorithmRunner.java
jwtc.chess.algorithm.UCIWrapper.java
jwtc.chess.board.BoardConstants.java
jwtc.chess.board.BoardHashKeys.java
jwtc.chess.board.BoardMembers.java
jwtc.chess.board.BoardStatics.java
jwtc.chess.board.ChessBoard.java