Some small fixes
This commit is contained in:
parent
31c700b738
commit
0fae09d687
4 changed files with 10 additions and 6 deletions
BIN
Zutil.jar
BIN
Zutil.jar
Binary file not shown.
6
src/zutil/db/bean/DBBean.java
Normal file → Executable file
6
src/zutil/db/bean/DBBean.java
Normal file → Executable file
|
|
@ -467,7 +467,6 @@ public abstract class DBBean {
|
||||||
|
|
||||||
// Set basic data type
|
// Set basic data type
|
||||||
if( o == null && !Object.class.isAssignableFrom( field.getType() ) ){
|
if( o == null && !Object.class.isAssignableFrom( field.getType() ) ){
|
||||||
logger.fine("Trying to set primitive data type to null!");
|
|
||||||
if( field.getType() == Integer.TYPE ) field.setInt(this, 0);
|
if( field.getType() == Integer.TYPE ) field.setInt(this, 0);
|
||||||
else if( field.getType() == Character.TYPE )field.setChar(this, (char) 0);
|
else if( field.getType() == Character.TYPE )field.setChar(this, (char) 0);
|
||||||
else if( field.getType() == Byte.TYPE ) field.setByte(this, (byte) 0);
|
else if( field.getType() == Byte.TYPE ) field.setByte(this, (byte) 0);
|
||||||
|
|
@ -477,8 +476,13 @@ public abstract class DBBean {
|
||||||
else if( field.getType() == Double.TYPE ) field.setDouble(this, 0d);
|
else if( field.getType() == Double.TYPE ) field.setDouble(this, 0d);
|
||||||
else if( field.getType() == Boolean.TYPE ) field.setBoolean(this, false);
|
else if( field.getType() == Boolean.TYPE ) field.setBoolean(this, false);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Some special cases
|
||||||
|
if(field.getType() == Boolean.TYPE && o instanceof Integer)
|
||||||
|
field.setBoolean(this, ((Integer)o) > 0 ); // Convert an Integer to boolean
|
||||||
else
|
else
|
||||||
field.set(this, o);
|
field.set(this, o);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.SEVERE, e.getMessage(), e);
|
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ public class Templator {
|
||||||
else
|
else
|
||||||
str.append(obj.toString());
|
str.append(obj.toString());
|
||||||
else
|
else
|
||||||
str.append("{{").append(tag).append("}}");
|
str.append("null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class TemplatorTest {
|
||||||
@Test
|
@Test
|
||||||
public void attributeEmptyTest(){
|
public void attributeEmptyTest(){
|
||||||
Templator tmpl = new Templator("<HTML>{{test}}</HTML>");
|
Templator tmpl = new Templator("<HTML>{{test}}</HTML>");
|
||||||
assertEquals("<HTML>{{test}}</HTML>", tmpl.compile());
|
assertEquals("<HTML>null</HTML>", tmpl.compile());
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void attributeSimpleTest() {
|
public void attributeSimpleTest() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue