org.nutz.lang.Lang.makeThrow()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.nutz.lang.Lang.makeThrow()方法的一些代码示例,展示了Lang.makeThrow()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lang.makeThrow()方法的具体详情如下:
包路径:org.nutz.lang.Lang
类名称:Lang
方法名:makeThrow

Lang.makeThrow介绍

[英]根据格式化字符串,生成一个指定的异常。
[中]根据格式化字符串,生成一个指定的异常。

代码示例

代码示例来源:origin: nutzam/nutz

public void invoke(Method m) {
    throw Lang.makeThrow(JsonException.class,
               "JsonField '%s' should be getter/setter pair!",
               m);
  }
};

代码示例来源:origin: nutzam/nutz

public LinkedCharArray(int size) {
  if (size <= 0)
    Lang.makeThrow("width must >0!");
  this.width = size;
  cache = new ArrayList<char[]>();
}

代码示例来源:origin: nutzam/nutz

public LinkedArray(Class<T> eleType, int size) {
  this.eleType = eleType;
  if (size <= 0)
    Lang.makeThrow("width must >0!");
  this.width = size;
  cache = new ArrayList<T[]>();
}

代码示例来源:origin: nutzam/nutz

public LinkedLongArray(int size) {
  if (size < 0)
    Lang.makeThrow("width must >0!");
  this.width = size;
  cache = new ArrayList<long[]>();
}

代码示例来源:origin: nutzam/nutz

public LinkedIntArray(int size) {
  if (size <= 0)
    Lang.makeThrow("width must >0!");
  this.width = size;
  cache = new ArrayList<int[]>();
}

代码示例来源:origin: nutzam/nutz

public Object born(Object... args) {
  // 第一个参数必须为整数
  if (args.length >= 1) {
    Object arg0 = args[0];
    if (arg0 instanceof Number) {
      return Array.newInstance(eleType, ((Number) arg0).intValue());
    }
  }
  throw Lang.makeThrow("array borning need length, arg0 should be number");
}

代码示例来源:origin: nutzam/nutz

public void invoke(Method method) {
    throw Lang.makeThrow(errmsgFormat,
               method.getName(),
               method.getDeclaringClass().getName());
  }
});

代码示例来源:origin: nutzam/nutz

public Object get(ServletContext sc, HttpServletRequest req, HttpServletResponse resp, Object refer) {
  throw Lang.makeThrow(    "Don't know how to inject %s.%s(...[%d]%s...),",
              method.getDeclaringClass(),
              method.getName(),
              index,
              method.getParameterTypes()[index]);
}

代码示例来源:origin: nutzam/nutz

@Override
public Map cast(Object src, Class<?> toType, String... args) throws FailToCastObjectException {
  if (null == args || args.length == 0)
    throw Lang.makeThrow(    FailToCastObjectException.class,
                "For the elements in array %s[], castors don't know which one is the key field.",
                src.getClass().getComponentType().getName());
  return Lang.array2map((Class<Map<Object, Object>>) toType, src, args[0]);
}

代码示例来源:origin: nutzam/nutz

public Email(String str) {
  try {
    int pos = str.indexOf('@');
    this.account = str.substring(0, pos);
    this.host = str.substring(pos + 1, str.length());
  }
  catch (Exception e) {
    throw Lang.makeThrow("Error email format [%s]", str);
  }
  if (Strings.isBlank(account) || Strings.isBlank(host) || host.indexOf('.') < 0)
    throw Lang.makeThrow("Error email format [%s]", str);
}

代码示例来源:origin: nutzam/nutz

@Override
public Map cast(Collection src, Class<?> toType, String... args)
    throws FailToCastObjectException {
  if (null == args || args.length == 0)
    throw Lang.makeThrow(    FailToCastObjectException.class,
                "For the elements in Collection %s, castors don't know which one is the key field.",
                src.getClass().getName());
  return Lang.collection2map((Class<Map<Object, Object>>) toType, src, args[0]);
}

代码示例来源:origin: nutzam/nutz

public String check(String key) {
  String val = get(key);
  if (null == val)
    throw Lang.makeThrow("Ioc.$conf expect property '%s'", key);
  return val;
}

代码示例来源:origin: nutzam/nutz

@SuppressWarnings("unchecked")
public <E extends Node<T>> void eachChild(Each<E> callback) {
  SimpleNode<T> nd = firstChild;
  int i = 0;
  while (nd != null) {
    callback.invoke(i++, (E) nd, -1);
    nd = nd.next;
    if (nd == firstChild)
      throw Lang.makeThrow("If i am here, tell me -_-!");
  }
}

代码示例来源:origin: nutzam/nutz

public static FloatSet make(String s) {
  if (s.length() < 3)
    throw Lang.makeThrow("Invalid FloatSet : '%s'", s);
  s = Strings.trim(s);
  char l = s.charAt(0);
  char r = s.charAt(s.length() - 1);
  FloatRange ir = FloatRange.make(s.substring(1, s.length() - 1));
  return new FloatSet(l, r, ir);
}

代码示例来源:origin: nutzam/nutz

public static IntSet make(String s) {
  if (s.length() < 3)
    throw Lang.makeThrow("Invalid IntSet : '%s'", s);
  s = Strings.trim(s);
  char l = s.charAt(0);
  char r = s.charAt(s.length() - 1);
  IntRange ir = IntRange.make(s.substring(1, s.length() - 1));
  return new IntSet(l, r, ir);
}

代码示例来源:origin: nutzam/nutz

public File createDir() {
  if (size > 0 && cursor >= size)
    cursor = -1;
  long id = ++cursor;
  if (size > 0 && id >= size)
    Lang.makeThrow("Id (%d) is out of range (%d)", id, size);
  return Files.createDirIfNoExists(Pools.getFilePathById(home, id, null));
}

代码示例来源:origin: nutzam/nutz

/**
 * 读取文件全部字节,并关闭文件
 * 
 * @param path
 *            文件路径
 * @return 文件的字节内容
 */
public static byte[] readBytes(String path) {
  File f = Files.findFile(path);
  if (null == f)
    throw Lang.makeThrow("Can not find file '%s'", path);
  return readBytes(f);
}

代码示例来源:origin: nutzam/nutz

public void addSql(String key, String value) {
  if (map().containsKey(key) && !allowDuplicate)
    throw Lang.makeThrow("duplicate key '%s'", key);
  key = Strings.trim(key);
  map().put(key, value);
  keylist().add(key);
}

代码示例来源:origin: nutzam/nutz

public ValueProxy makeValue(IocValue iv) {
    for (ValueProxyMaker vpm : vpms) {
      ValueProxy vp = vpm.make(this, iv);
      if (null != vp)
        return vp;
    }
    throw Lang.makeThrow(    "Unknown value {'%s':%s} for object [%s]",
                iv.getType(),
                Json.toJson(iv.getValue()),
                objectName);
  }
}

代码示例来源:origin: nutzam/nutz

public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
  Entity<?> en = sql.getEntity();
  if (null == en)
    throw Lang.makeThrow("SQL without entity : %s", sql.toString());
  FieldMatcher fmh = sql.getContext().getFieldMatcher();
  if (null == fmh)
    sql.getContext().setFieldMatcher(FieldFilter.get(en.getType()));
  return process(rs, en, sql.getContext());
}

相关文章