Example usage for java.lang Object Object

List of usage examples for java.lang Object Object

Introduction

In this page you can find the example usage for java.lang Object Object.

Prototype

@HotSpotIntrinsicCandidate
public Object() 

Source Link

Document

Constructs a new object.

Usage

From source file:Main.java

public static void startActAnim(Activity activity, int inAnim, int outAnim) {

    if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT) {
        new Object() {
            public void overridePendingTransition(Activity act, int i, int j) {
                act.overridePendingTransition(i, j);
            }/*from   ww w. j a v  a2s . com*/
        }.overridePendingTransition(activity, inAnim, outAnim);
    }
}

From source file:ListDemoHead.java

static long timeList(List list) {
    long start = System.currentTimeMillis();
    Object obj = new Object();
    for (int i = 0; i < SIZE; i++) {
        // add object to the head of the list
        list.add(0, obj);/*from w w  w. j a v a2 s.  com*/
    }

    return System.currentTimeMillis() - start;
}

From source file:ListDemo.java

static long timeList(List list) {
    long start = System.currentTimeMillis();
    Object obj = new Object();

    for (int i = 0; i < SIZE; i++) {
        // add object to the rear of the list
        list.add(obj);/* w w  w.j a v  a 2  s . co m*/
    }

    return System.currentTimeMillis() - start;
}

From source file:Main.java

public static Object readObj(String fileName) {
    Object obj = new Object();
    try {/*www  . j ava  2  s  .  com*/
        FileInputStream fin = new FileInputStream(fileName);
        ObjectInputStream oin = new ObjectInputStream(fin);
        obj = oin.readObject();
        fin.close();
        oin.close();
    } catch (Exception e) {
        printE("OpusTool", e);
    } finally {
        return obj;
    }
}

From source file:Main.java

public static final String randomString(int length) {
    Random randGen = null;//w w w. ja v a 2s.co m
    char[] numbersAndLetters = null;
    Object initLock = new Object();
    if (length < 1) {
        return null;
    }
    if (randGen == null) {
        synchronized (initLock) {
            if (randGen == null) {
                randGen = new Random();
                numbersAndLetters = ("0123456789abcdefghijklmnopqrstuvwxyz"
                        + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray();
            }
        }
    }
    char[] randBuffer = new char[length];
    for (int i = 0; i < randBuffer.length; i++) {
        randBuffer[i] = numbersAndLetters[randGen.nextInt(71)];
    }
    return new String(randBuffer);
}

From source file:Main.java

public static void debugWait(long time) {

    if (!debug)/*from   www .j av  a 2 s  .  c o  m*/
        return;

    if (wait == null)
        wait = new Object();

    synchronized (wait) {

        try {
            wait.wait(time);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}

From source file:com.job.portal.utils.BeanUtils.java

public static Map<String, Object> convertToMap(Object bean) {
    Map<String, Object> m = new HashMap<String, Object>();
    try {//from w w  w  .java  2  s. co m
        for (Field field : bean.getClass().getDeclaredFields()) {
            field.setAccessible(true); // You might want to set modifier to public first.
            Object value = field.get(bean);
            if (value != null) {
                m.put(field.getName(), value);
            }
        }
    } catch (Exception e) {
        LogOut.log.error("In " + new Object() {
        }.getClass().getEnclosingClass().getName() + "." + new Object() {
        }.getClass().getEnclosingMethod().getName() + " " + e);
    }
    return m;
}

From source file:Main.java

public static double eval(final String str) {
    return new Object() {
        private int pos = -1, ch;

        void nextChar() {
            ch = (++pos < str.length()) ? str.charAt(pos) : -1;
        }//from w  w  w  .  jav a 2s  .  c o m

        boolean eat(int charToEat) {
            while (ch == ' ') {
                nextChar();
            }
            if (ch == charToEat) {
                nextChar();
                return true;
            }
            return false;
        }

        double parse() {
            nextChar();
            double x = parseExpression();
            if (pos < str.length()) {
                throw new IllegalArgumentException("Unexpected: " + (char) ch);
            }
            return x;
        }

        // Grammar:
        // expression = term | expression `+` term | expression `-` term
        // term = factor | term `*` factor | term `/` factor
        // factor = `+` factor | `-` factor | `(` expression `)`
        //        | number | functionName factor | factor `^` factor

        double parseExpression() {
            double x = parseTerm();
            for (;;) {
                if (eat('+')) {
                    x += parseTerm(); // addition
                } else {
                    if (eat('-')) {
                        x -= parseTerm(); // subtraction
                    } else {
                        return x;
                    }
                }
            }
        }

        double parseTerm() {
            double x = parseFactor();
            for (;;) {
                if (eat('*')) {
                    x *= parseFactor(); // multiplication
                } else {
                    if (eat('/')) {
                        x /= parseFactor(); // division
                    } else {
                        return x;
                    }
                }
            }
        }

        double parseFactor() {
            if (eat('+')) {
                return parseFactor(); // unary plus
            }
            if (eat('-')) {
                return -parseFactor(); // unary minus
            }

            double x;
            int startPos = this.pos;
            if (eat('(')) { // parentheses
                x = parseExpression();
                eat(')');
            } else if ((ch >= '0' && ch <= '9') || ch == '.') { // numbers
                while ((ch >= '0' && ch <= '9') || ch == '.') {
                    nextChar();
                }
                x = Double.parseDouble(str.substring(startPos, this.pos));
            } else if (ch >= 'a' && ch <= 'z') { // functions
                while (ch >= 'a' && ch <= 'z') {
                    nextChar();
                }
                String func = str.substring(startPos, this.pos);
                x = parseFactor();
                switch (func) {
                case "sqrt":
                    x = Math.sqrt(x);
                    break;
                case "sin":
                    x = Math.sin(Math.toRadians(x));
                    break;
                case "cos":
                    x = Math.cos(Math.toRadians(x));
                    break;
                case "tan":
                    x = Math.tan(Math.toRadians(x));
                    break;
                default:
                    throw new IllegalArgumentException("Unknown function: " + func);
                }
            } else {
                throw new IllegalArgumentException("Unexpected: " + (char) ch);
            }

            if (eat('^')) {
                x = Math.pow(x, parseFactor()); // exponentiation
            }

            return x;
        }
    }.parse();
}

From source file:SyncBlock.java

public SyncBlock() {
    longLock = new Object();
}

From source file:Wake.java

public void stopOne() {
    Object myLock = new Object();
    synchronized (myLock) {
        stopped.addElement(myLock);//from   w  w  w .  j  ava 2 s.c om
        try {
            myLock.wait();
        } catch (InterruptedException e) {
        }
    }
}