本文整理了Java中org.apache.openjpa.kernel.Filters.canConvert()
方法的一些代码示例,展示了Filters.canConvert()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Filters.canConvert()
方法的具体详情如下:
包路径:org.apache.openjpa.kernel.Filters
类名称:Filters
方法名:canConvert
[英]Return whether an instance of the first class can be converted to an instance of the second.
[中]
代码示例来源:origin: org.apache.openjpa/openjpa-persistence
public boolean selects(Attribute<? super X, ?> attr) {
boolean result = _type == null || Filters.canConvert(attr.getJavaType(), _type, false);
return _invert ? !result : result;
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-persistence
public boolean selects(Attribute<? super X, ?> attr) {
boolean result = _type == null || Filters.canConvert(attr.getJavaType(), _type, false);
return _invert ? !result : result;
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
public boolean selects(Attribute<? super X, ?> attr) {
boolean result = _type == null || Filters.canConvert(attr.getJavaType(), _type, false);
return _invert ? !result : result;
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
public boolean selects(Attribute<? super X, ?> attr) {
boolean result = _type == null || Filters.canConvert(attr.getJavaType(), _type, false);
return _invert ? !result : result;
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel
/**
* Ensure that conversion is possible.
*/
private void assertConvertable(Class<?> candidate, Class<?>[] types,
Class<?> resultClass) {
Class<?> c = (types == null) ? candidate : types[0];
if ((types != null && types.length != 1) || (c != null
&& c != Object.class && !Filters.canConvert(c, resultClass, true)))
throw new UserException(_loc.get("cant-convert-result",
c, resultClass));
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
/**
* Ensure that conversion is possible.
*/
private void assertConvertable(Class<?> candidate, Class<?>[] types,
Class<?> resultClass) {
Class<?> c = (types == null) ? candidate : types[0];
if ((types != null && types.length != 1) || (c != null
&& c != Object.class && !Filters.canConvert(c, resultClass, true)))
throw new UserException(_loc.get("cant-convert-result",
c, resultClass));
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
/**
* Ensure that conversion is possible.
*/
private void assertConvertable(Class<?> candidate, Class<?>[] types,
Class<?> resultClass) {
Class<?> c = (types == null) ? candidate : types[0];
if ((types != null && types.length != 1) || (c != null
&& c != Object.class && !Filters.canConvert(c, resultClass, true)))
throw new UserException(_loc.get("cant-convert-result",
c, resultClass));
}
代码示例来源:origin: org.apache.openjpa/openjpa-kernel
/**
* Ensure that conversion is possible.
*/
private void assertConvertable(Class<?> candidate, Class<?>[] types,
Class<?> resultClass) {
Class<?> c = (types == null) ? candidate : types[0];
if ((types != null && types.length != 1) || (c != null
&& c != Object.class && !Filters.canConvert(c, resultClass, true)))
throw new UserException(_loc.get("cant-convert-result",
c, resultClass));
}
代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa
/**
* Ensure that conversion is possible.
*/
private void assertConvertable(Class candidate, Class[] types,
Class resultClass) {
Class c = (types == null) ? candidate : types[0];
if ((types != null && types.length != 1) || (c != null
&& c != Object.class && !Filters.canConvert(c, resultClass, true)))
throw new UserException(_loc.get("cant-convert-result",
c, resultClass));
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel
private static void validateParameterValue(Object key, Object value,
Class expected) {
if (expected == null)
return;
if (value == null) {
if (expected.isPrimitive())
throw new UserException(_loc.get("null-primitive-param",
key, expected));
} else {
Class actual = value.getClass();
boolean strict = true;
if (!Filters.canConvert(actual, expected, strict))
throw new UserException(_loc.get("param-value-mismatch",
new Object[]{key, expected, value, actual}));
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
private static void validateParameterValue(Object key, Object value,
Class expected) {
if (expected == null)
return;
if (value == null) {
if (expected.isPrimitive())
throw new UserException(_loc.get("null-primitive-param",
key, expected));
} else {
Class actual = value.getClass();
boolean strict = true;
if (!Filters.canConvert(actual, expected, strict))
throw new UserException(_loc.get("param-value-mismatch",
new Object[]{key, expected, value, actual}));
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-kernel
private static void validateParameterValue(Object key, Object value,
Class expected) {
if (expected == null)
return;
if (value == null) {
if (expected.isPrimitive())
throw new UserException(_loc.get("null-primitive-param",
key, expected));
} else {
Class actual = value.getClass();
boolean strict = true;
if (!Filters.canConvert(actual, expected, strict))
throw new UserException(_loc.get("param-value-mismatch",
new Object[]{key, expected, value, actual}));
}
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
private static void validateParameterValue(Object key, Object value,
Class expected) {
if (expected == null)
return;
if (value == null) {
if (expected.isPrimitive())
throw new UserException(_loc.get("null-primitive-param",
key, expected));
} else {
Class actual = value.getClass();
boolean strict = true;
if (!Filters.canConvert(actual, expected, strict))
throw new UserException(_loc.get("param-value-mismatch",
new Object[]{key, expected, value, actual}));
}
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-jdbc
public void appendTo(Select sel, ExpContext ctx, ExpState state,
SQLBuffer buf) {
BinaryOpExpState bstate = (BinaryOpExpState) state;
_val1.calculateValue(sel, ctx, bstate.state1, _val2, bstate.state2);
_val2.calculateValue(sel, ctx, bstate.state2, _val1, bstate.state1);
Class val1Type = _val1.getType();
Class val2Type = _val2.getType();
// For purposes of the 'canConvert', when dealing with a Lit with Raw
// use a String type since Raw contains a String.
if (_val1 instanceof Lit && val1Type.isAssignableFrom(Raw.class)){
val1Type = String.class;
}
if (_val2 instanceof Lit && val2Type.isAssignableFrom(Raw.class)){
val2Type = String.class;
}
if (!Filters.canConvert(val1Type, val2Type, false)
&& !Filters.canConvert(val2Type, val1Type, false))
throw new UserException(_loc.get("cant-convert", val1Type, val2Type));
ctx.store.getDBDictionary().comparison(buf, _op,
new FilterValueImpl(sel, ctx, bstate.state1, _val1),
new FilterValueImpl(sel, ctx, bstate.state2, _val2));
if (sel != null)
sel.append(buf, state.joins);
}
代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa
public void appendTo(Select sel, ExpContext ctx, ExpState state,
SQLBuffer buf) {
BinaryOpExpState bstate = (BinaryOpExpState) state;
_val1.calculateValue(sel, ctx, bstate.state1, _val2, bstate.state2);
_val2.calculateValue(sel, ctx, bstate.state2, _val1, bstate.state1);
if (!Filters.canConvert(_val1.getType(), _val2.getType(), false)
&& !Filters.canConvert(_val2.getType(), _val1.getType(), false))
throw new UserException(_loc.get("cant-convert", _val1.getType(),
_val2.getType()));
ctx.store.getDBDictionary().comparison(buf, _op,
new FilterValueImpl(sel, ctx, bstate.state1, _val1),
new FilterValueImpl(sel, ctx, bstate.state2, _val2));
sel.append(buf, state.joins);
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
public void appendTo(Select sel, ExpContext ctx, ExpState state,
SQLBuffer buf) {
BinaryOpExpState bstate = (BinaryOpExpState) state;
_val1.calculateValue(sel, ctx, bstate.state1, _val2, bstate.state2);
_val2.calculateValue(sel, ctx, bstate.state2, _val1, bstate.state1);
if (!Filters.canConvert(_val1.getType(), _val2.getType(), false)
&& !Filters.canConvert(_val2.getType(), _val1.getType(), false))
throw new UserException(_loc.get("cant-convert", _val1.getType(),
_val2.getType()));
boolean val1Null = _val1 instanceof Const
&& ((Const) _val1).isSQLValueNull(sel, ctx, bstate.state1);
boolean val2Null = _val2 instanceof Const
&& ((Const) _val2).isSQLValueNull(sel, ctx, bstate.state2);
appendTo(sel, ctx, bstate, buf, val1Null, val2Null);
if (sel != null)
sel.append(buf, state.joins);
}
代码示例来源:origin: org.apache.openjpa/openjpa-jdbc
public void appendTo(Select sel, ExpContext ctx, ExpState state,
SQLBuffer buf) {
BinaryOpExpState bstate = (BinaryOpExpState) state;
_val1.calculateValue(sel, ctx, bstate.state1, _val2, bstate.state2);
_val2.calculateValue(sel, ctx, bstate.state2, _val1, bstate.state1);
if (!Filters.canConvert(_val1.getType(), _val2.getType(), false)
&& !Filters.canConvert(_val2.getType(), _val1.getType(), false))
throw new UserException(_loc.get("cant-convert", _val1.getType(),
_val2.getType()));
boolean val1Null = _val1 instanceof Const
&& ((Const) _val1).isSQLValueNull(sel, ctx, bstate.state1);
boolean val2Null = _val2 instanceof Const
&& ((Const) _val2).isSQLValueNull(sel, ctx, bstate.state2);
appendTo(sel, ctx, bstate, buf, val1Null, val2Null);
if (sel != null)
sel.append(buf, state.joins);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa
public void appendTo(Select sel, ExpContext ctx, ExpState state,
SQLBuffer buf) {
BinaryOpExpState bstate = (BinaryOpExpState) state;
_val1.calculateValue(sel, ctx, bstate.state1, _val2, bstate.state2);
_val2.calculateValue(sel, ctx, bstate.state2, _val1, bstate.state1);
if (!Filters.canConvert(_val1.getType(), _val2.getType(), false)
&& !Filters.canConvert(_val2.getType(), _val1.getType(), false))
throw new UserException(_loc.get("cant-convert", _val1.getType(),
_val2.getType()));
boolean val1Null = _val1 instanceof Const
&& ((Const) _val1).isSQLValueNull(sel, ctx, bstate.state1);
boolean val2Null = _val2 instanceof Const
&& ((Const) _val2).isSQLValueNull(sel, ctx, bstate.state2);
appendTo(sel, ctx, bstate, buf, val1Null, val2Null);
if (sel != null)
sel.append(buf, state.joins);
}
代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa
public void appendTo(Select sel, ExpContext ctx, ExpState state,
SQLBuffer buf) {
BinaryOpExpState bstate = (BinaryOpExpState) state;
_val1.calculateValue(sel, ctx, bstate.state1, _val2, bstate.state2);
_val2.calculateValue(sel, ctx, bstate.state2, _val1, bstate.state1);
if (!Filters.canConvert(_val1.getType(), _val2.getType(), false)
&& !Filters.canConvert(_val2.getType(), _val1.getType(), false))
throw new UserException(_loc.get("cant-convert", _val1.getType(),
_val2.getType()));
boolean val1Null = _val1 instanceof Const
&& ((Const) _val1).isSQLValueNull(sel, ctx, bstate.state1);
boolean val2Null = _val2 instanceof Const
&& ((Const) _val2).isSQLValueNull(sel, ctx, bstate.state2);
appendTo(sel, ctx, bstate, buf, val1Null, val2Null);
sel.append(buf, state.joins);
}
代码示例来源:origin: org.apache.openejb.patch/openjpa-jdbc
public void appendTo(Select sel, ExpContext ctx, ExpState state,
SQLBuffer buf) {
BinaryOpExpState bstate = (BinaryOpExpState) state;
_val1.calculateValue(sel, ctx, bstate.state1, _val2, bstate.state2);
_val2.calculateValue(sel, ctx, bstate.state2, _val1, bstate.state1);
if (!Filters.canConvert(_val1.getType(), _val2.getType(), false)
&& !Filters.canConvert(_val2.getType(), _val1.getType(), false))
throw new UserException(_loc.get("cant-convert", _val1.getType(),
_val2.getType()));
boolean val1Null = _val1 instanceof Const
&& ((Const) _val1).isSQLValueNull(sel, ctx, bstate.state1);
boolean val2Null = _val2 instanceof Const
&& ((Const) _val2).isSQLValueNull(sel, ctx, bstate.state2);
appendTo(sel, ctx, bstate, buf, val1Null, val2Null);
if (sel != null)
sel.append(buf, state.joins);
}
内容来源于网络,如有侵权,请联系作者删除!