java类java.beans.Statement的实例源码

ClassForName.java 文件源码 项目:openjdk-jdk10 阅读 20 收藏 0 点赞 0 评论 0
private static void simpleTest() throws Exception {
    // load the class without initialization
    new Statement(Class.class, "forName", new Object[]{
            "ClassForName$Bean", false, Bean.class.getClassLoader()
    }).execute();
    if (initialized) {
        throw new RuntimeException("Should not be initialized");
    }

    // load the class and initialize it
    new Statement(Class.class, "forName", new Object[]{
            "ClassForName$Bean", true, Bean.class.getClassLoader()
    }).execute();
    if (!initialized) {
        throw new RuntimeException("Should be initialized");
    }
}
ObjectUtil.java 文件源码 项目:oson 阅读 27 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
public static <E> void setMethodValue(E obj, Method method, Object... args) {
    try {
        method.setAccessible(true);

        method.invoke(obj, args);

    } catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
        // e.printStackTrace();
        try {
            if (obj != null) {
                Statement stmt = new Statement(obj, method.getName(), args);
                stmt.execute();
            }

        } catch (Exception e1) {
            // e1.printStackTrace();
        }
    }
}
Utilities.java 文件源码 项目:hive-phoenix-handler 阅读 28 收藏 0 点赞 0 评论 0
public static void setQueryTimeout(java.sql.Statement stmt, int timeout) throws SQLException {
  if (timeout < 0) {
    LOG.info("Invalid query timeout " + timeout);
    return;
  }
  try {
    stmt.setQueryTimeout(timeout);
  } catch (SQLException e) {
    String message = e.getMessage() == null ? null : e.getMessage().toLowerCase();
    if (e instanceof SQLFeatureNotSupportedException ||
       (message != null && (message.contains("implemented") || message.contains("supported")))) {
      LOG.info("setQueryTimeout is not supported");
      return;
    }
    throw e;
  }
}
PainterUtil.java 文件源码 项目:swingx 阅读 18 收藏 0 点赞 0 评论 0
@Override
        protected void initialize(Class type, Object oldInstance,
                Object newInstance, Encoder out) {
//            p("image painter delegate called");
            super.initialize(type, oldInstance,  newInstance, out);
            //p("old instance = " + oldInstance);
            //p("owner = " + ((XMLEncoder)out).getOwner());
            PersistenceOwner owner = (PersistenceOwner)((XMLEncoder)out).getOwner();
            ImagePainter ip = (ImagePainter)oldInstance;
//            p("need to convert string: " + ip.getImageString());
//            String s = owner.toXMLURL(ip.getImageString());
//            p("converted to: " + s);
                //out.writeExpression(new Expression(oldInstance,owner,"fromXMLURL",new Object[]{ip.getImageString()}));
                //out.writeStatement(new Statement(owner,"fromXMLURL",new Object[]{ip.getImageString()}));
                //out.writeStatement(new Statement(oldInstance,"setImageString",new Object[]{
                //new Expression(oldInstance,owner,"fromXMLURL",new Object[]{ip.getImageString()})
                //}));

            out.writeStatement(new Statement(oldInstance,"setResolver",new Object[]{owner}));
//            out.writeStatement(new Statement(oldInstance,"setImageString",new Object[]{s}));
        }
DefaultPersistenceDelegateTest.java 文件源码 项目:cn1 阅读 17 收藏 0 点赞 0 评论 0
public void testInitialize_NormalBeanInfo() throws Exception {
    CollectingEncoder enc = new CollectingEncoder();
    MockPersistenceDelegate pd = new MockPersistenceDelegate();
    MockFoo2 b = new MockFoo2(2);
    MockFoo2 b2 = new MockFoo2(3);
    Iterator<Statement> iter;

    pd.writeObject(b, enc);
    pd.writeObject(b2, enc);
    enc.clearCache();
    pd.initialize(MockFoo2.class, b, b2, enc);

    // XXX RI stores much more statements to the stream
    iter = enc.statements();
    // assertNotNull("required statement not found",
    // findStatement(iter, b, "myget", null));
    assertNotNull("required statement not found", findStatement(iter, null,
            "myset", new Object[] { new Integer(2) }));
}
AppConfigTableModel.java 文件源码 项目:dli-downloader 阅读 17 收藏 0 点赞 0 评论 0
public void setValueAt(Object obj, int row, int col) {
    Field field = data.get(row);
    if (field != null) {
        try {
            switch (col) {
                case 1:
                    if (field.getType().getSimpleName().equalsIgnoreCase("int")) {
                        new Statement(appContext, methods.get("set" + field.getName().toLowerCase()).getName(), new Object[]{Integer.parseInt((String) obj)}).execute();
                    } else if (field.getType().getSimpleName().equalsIgnoreCase("boolean")) {
                        field.set(appContext, Boolean.parseBoolean((String) obj));
                    } else if (field.getType().getSimpleName().equalsIgnoreCase("string")) {
                        field.set(appContext, obj);
                    }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    super.fireTableDataChanged();
}
DefaultPersistenceDelegateTest.java 文件源码 项目:freeVM 阅读 20 收藏 0 点赞 0 评论 0
public void testInitialize_NormalBeanInfo() throws Exception {
    CollectingEncoder enc = new CollectingEncoder();
    MockPersistenceDelegate pd = new MockPersistenceDelegate();
    MockFoo2 b = new MockFoo2(2);
    MockFoo2 b2 = new MockFoo2(3);
    Iterator<Statement> iter;

    pd.writeObject(b, enc);
    pd.writeObject(b2, enc);
    enc.clearCache();
    pd.initialize(MockFoo2.class, b, b2, enc);

    // XXX RI stores much more statements to the stream
    iter = enc.statements();
    // assertNotNull("required statement not found",
    // findStatement(iter, b, "myget", null));
    assertNotNull("required statement not found", findStatement(iter, null,
            "myset", new Object[] { new Integer(2) }));
}
Test8013416.java 文件源码 项目:jdk8u-jdk 阅读 30 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
    super.initialize(type, oldInstance, newInstance, out);

    Public<String, String> map = (Public) oldInstance;
    for (Entry<String, String> entry : map.getAll()) {
        String[] args = {entry.getKey(), entry.getValue()};
        out.writeStatement(new Statement(oldInstance, "put", args));
    }
}
Test8005065.java 文件源码 项目:jdk8u-jdk 阅读 27 收藏 0 点赞 0 评论 0
private static void testStatement() {
    Object[] array = { new Object() };
    Statement statement = new Statement(null, null, array);
    test(statement.getArguments());
    array[0] = null;
    test(statement.getArguments());
    statement.getArguments()[0] = null;
    test(statement.getArguments());
}
Test8013416.java 文件源码 项目:openjdk-jdk10 阅读 18 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
    super.initialize(type, oldInstance, newInstance, out);

    Public<String, String> map = (Public) oldInstance;
    for (Entry<String, String> entry : map.getAll()) {
        String[] args = {entry.getKey(), entry.getValue()};
        out.writeStatement(new Statement(oldInstance, "put", args));
    }
}
Test8005065.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
private static void testStatement() {
    Object[] array = { new Object() };
    Statement statement = new Statement(null, null, array);
    test(statement.getArguments());
    array[0] = null;
    test(statement.getArguments());
    statement.getArguments()[0] = null;
    test(statement.getArguments());
}
Test8013416.java 文件源码 项目:openjdk9 阅读 20 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
    super.initialize(type, oldInstance, newInstance, out);

    Public<String, String> map = (Public) oldInstance;
    for (Entry<String, String> entry : map.getAll()) {
        String[] args = {entry.getKey(), entry.getValue()};
        out.writeStatement(new Statement(oldInstance, "put", args));
    }
}
Test8005065.java 文件源码 项目:openjdk9 阅读 26 收藏 0 点赞 0 评论 0
private static void testStatement() {
    Object[] array = { new Object() };
    Statement statement = new Statement(null, null, array);
    test(statement.getArguments());
    array[0] = null;
    test(statement.getArguments());
    statement.getArguments()[0] = null;
    test(statement.getArguments());
}
Utilities.java 文件源码 项目:hive-phoenix-handler 阅读 23 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
  java.util.Collection oldO = (java.util.Collection) oldInstance;
  java.util.Collection newO = (java.util.Collection) newInstance;

  if (newO.size() != 0) {
    out.writeStatement(new Statement(oldInstance, "clear", new Object[] {}));
  }
  for (Iterator i = oldO.iterator(); i.hasNext();) {
    out.writeStatement(new Statement(oldInstance, "add", new Object[] {i.next()}));
  }
}
Utilities.java 文件源码 项目:hive-phoenix-handler 阅读 21 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
  java.util.Collection oldO = (java.util.Collection) oldInstance;
  java.util.Collection newO = (java.util.Collection) newInstance;

  if (newO.size() != 0) {
    out.writeStatement(new Statement(oldInstance, "clear", new Object[] {}));
  }
  for (Iterator i = oldO.iterator(); i.hasNext();) {
    out.writeStatement(new Statement(oldInstance, "add", new Object[] {i.next()}));
  }
}
Utilities.java 文件源码 项目:hive-phoenix-handler 阅读 21 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
  java.util.Collection oldO = (java.util.Collection) oldInstance;
  java.util.Collection newO = (java.util.Collection) newInstance;

  if (newO.size() != 0) {
    out.writeStatement(new Statement(oldInstance, "clear", new Object[] {}));
  }
  for (Iterator i = oldO.iterator(); i.hasNext();) {
    out.writeStatement(new Statement(oldInstance, "add", new Object[] {i.next()}));
  }
}
Utilities.java 文件源码 项目:hive-phoenix-handler 阅读 29 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
  Timestamp ts = (Timestamp)oldInstance;
  Object[] args = { ts.getNanos() };
  Statement stmt = new Statement(oldInstance, "setNanos", args);
  out.writeStatement(stmt);
}
Utilities.java 文件源码 项目:hive-phoenix-handler 阅读 24 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out) {
  Iterator ite = ((Collection) oldInstance).iterator();
  while (ite.hasNext()) {
    out.writeStatement(new Statement(oldInstance, "add", new Object[] {ite.next()}));
  }
}
Test8013416.java 文件源码 项目:jdk8u_jdk 阅读 33 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
    super.initialize(type, oldInstance, newInstance, out);

    Public<String, String> map = (Public) oldInstance;
    for (Entry<String, String> entry : map.getAll()) {
        String[] args = {entry.getKey(), entry.getValue()};
        out.writeStatement(new Statement(oldInstance, "put", args));
    }
}
Test8005065.java 文件源码 项目:jdk8u_jdk 阅读 23 收藏 0 点赞 0 评论 0
private static void testStatement() {
    Object[] array = { new Object() };
    Statement statement = new Statement(null, null, array);
    test(statement.getArguments());
    array[0] = null;
    test(statement.getArguments());
    statement.getArguments()[0] = null;
    test(statement.getArguments());
}
Test8013416.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 22 收藏 0 点赞 0 评论 0
@Override
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
    super.initialize(type, oldInstance, newInstance, out);

    Public<String, String> map = (Public) oldInstance;
    for (Entry<String, String> entry : map.getAll()) {
        String[] args = {entry.getKey(), entry.getValue()};
        out.writeStatement(new Statement(oldInstance, "put", args));
    }
}
Test8005065.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 21 收藏 0 点赞 0 评论 0
private static void testStatement() {
    Object[] array = { new Object() };
    Statement statement = new Statement(null, null, array);
    test(statement.getArguments());
    array[0] = null;
    test(statement.getArguments());
    statement.getArguments()[0] = null;
    test(statement.getArguments());
}
CollectionPersistenceDelegate.java 文件源码 项目:javify 阅读 18 收藏 0 点赞 0 评论 0
protected void initialize(Class type, Object oldInstance, Object newInstance,
                          Encoder out)
{
  Iterator ite = ((Collection) oldInstance).iterator();

  while (ite.hasNext())
    {
      out.writeStatement(new Statement(oldInstance, "add",
                                       new Object[] { ite.next() }));

    }

}
ScanEngine.java 文件源码 项目:javify 阅读 21 收藏 0 点赞 0 评论 0
/** Scans the argument and calls one of event methods. See
 * the introduction of this class for details.
 *
 * @param stmt The statement to serialize.
 */
public void writeStatement(Statement stmt)
{
  // This is a simplified version of writeExpression. Everything
  // that would not create something that is embedded in a <void> tag
  // is left out (instantiation, getters, ...).
  // TODO: Is this the right thing to do?

  String methodName = stmt.getMethodName();
  Object target = stmt.getTarget();
  Object[] args = stmt.getArguments();

  if (target == Array.class && methodName.equals("set"))
    {
      arraySet(args[1].toString());
      return;
    }

  if (target instanceof List)
    {
      if (methodName.equals("set"))
        {
          listSet();
          return;
        }
    }

  // If nothing else could be used then this is a normal
  // method invocation.
  methodInvocation(methodName);
}
MapPersistenceDelegate.java 文件源码 项目:javify 阅读 19 收藏 0 点赞 0 评论 0
protected void initialize(Class type, Object oldInstance, Object newInstance,
                          Encoder out)
{
  Map map = (Map) oldInstance;
  Iterator ite = map.keySet().iterator();

  while (ite.hasNext())
    {
      Object key = ite.next();
      out.writeStatement(new Statement(oldInstance, "put",
                                       new Object[] { key, map.get(key) }));

    }

}
CollectionPersistenceDelegate.java 文件源码 项目:jvm-stm 阅读 19 收藏 0 点赞 0 评论 0
protected void initialize(Class type, Object oldInstance, Object newInstance,
                          Encoder out)
{
  Iterator ite = ((Collection) oldInstance).iterator();

  while (ite.hasNext())
    {
      out.writeStatement(new Statement(oldInstance, "add",
                                       new Object[] { ite.next() }));

    }

}
ScanEngine.java 文件源码 项目:jvm-stm 阅读 20 收藏 0 点赞 0 评论 0
/** Scans the argument and calls one of event methods. See
 * the introduction of this class for details.
 * 
 * @param stmt The statement to serialize.
 */
public void writeStatement(Statement stmt)
{
  // This is a simplified version of writeExpression. Everything
  // that would not create something that is embedded in a <void> tag
  // is left out (instantiation, getters, ...).
  // TODO: Is this the right thing to do?

  String methodName = stmt.getMethodName();
  Object target = stmt.getTarget();
  Object[] args = stmt.getArguments();

  if (target == Array.class && methodName.equals("set"))
    {
      arraySet(args[1].toString());
      return;
    }

  if (target instanceof List)
    {
      if (methodName.equals("set"))
        {
          listSet();
          return;
        }
    }

  // If nothing else could be used then this is a normal
  // method invocation.
  methodInvocation(methodName);
}
MapPersistenceDelegate.java 文件源码 项目:jvm-stm 阅读 21 收藏 0 点赞 0 评论 0
protected void initialize(Class type, Object oldInstance, Object newInstance,
                          Encoder out)
{
  Map map = (Map) oldInstance;
  Iterator ite = map.keySet().iterator();

  while (ite.hasNext())
    {
      Object key = ite.next();
      out.writeStatement(new Statement(oldInstance, "put",
                                       new Object[] { key, map.get(key) }));

    }

}
BoundAction.java 文件源码 项目:swingx 阅读 35 收藏 0 点赞 0 评论 0
public BooleanInvocationHandler(Object target, String methodName) {
    // Create the true and false statements.
    falseStatement = new Statement(target, methodName, 
                                   new Object[] { Boolean.FALSE });

    trueStatement = new Statement(target, methodName, 
                                  new Object[] { Boolean.TRUE });
}
BoundAction.java 文件源码 项目:swingx 阅读 19 收藏 0 点赞 0 评论 0
@Override
public void itemStateChanged(ItemEvent evt) {
    Statement statement = (evt.getStateChange() == ItemEvent.DESELECTED) ? falseStatement
            : trueStatement;

    try {
        statement.execute();
    } catch (Exception ex) {
        LOG.log(Level.FINE,
                "Couldn't execute boolean method via Statement "
                        + statement, ex);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号