Project

General

Profile

Anomalie #1210

Parser java with default value

Added by Mickael G. almost 7 years ago. Updated almost 7 years ago.

Status:
Fermé
Priority:
Haut
Assignee:
Gregg C.
Category:
-
Target version:
Start date:
12/12/2012
Due date:
% Done:

100%

Estimated time:

Description

L'annotation :

@Column
protected boolean validate = false;

génère :

/**
 * @return the validate = false
*/
public boolean getValidate = false() {
return this.validate = false;
}
/**
 * @param value the validate = false to set
*/
public void setValidate = false(boolean value) {
this.validate = false = value;
}
public static final String COL_VALIDATE = FALSE = "validate = false";
/** Global Fields */
public static final String[] COLS = new String[] {
COL_CONTENT,
COL_ID,
COL_CREATEDAT,
COL_VALIDATE = FALSE,
REF_POST_ID,
REF_USER_ID
};
/** Generate Entity Table Schema
 * 
 * return "SQL query : CREATE TABLE..." 
*/
public static final String getSchema() {
return "CREATE TABLE "
+ TABLE_NAME + " ("
+ COL_CONTENT + " string(2000) NOT NULL ,"
+ COL_ID + " int NOT NULL PRIMARY KEY ,"
+ REF_POST_ID + " int NOT NULL,"
+ COL_CREATEDAT + " date NOT NULL ,"
+ REF_USER_ID + " int NOT NULL,"
+ COL_VALIDATE = FALSE + " boolean NOT NULL ,"
+ "FOREIGN KEY("+REF_POST_ID+") REFERENCES Post("+PostAdapterBase.COL_ID+"),"
+ "FOREIGN KEY("+REF_USER_ID+") REFERENCES User("+UserAdapterBase.COL_ID+")"
+ ");";
}
// Converters
/** Convert Comment entity to Content Values for database * * param comment Comment entity object * return ContentValues object
*/
public static ContentValues commentToContentValues(Comment comment) {
ContentValues result = new ContentValues();
result.put(COL_CONTENT, String.valueOf(comment.getContent()) );
result.put(COL_ID, String.valueOf(comment.getId()) );
result.put(COL_CREATEDAT, String.valueOf(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(comment.getCreatedAt())) );
result.put(COL_VALIDATE = FALSE, String.valueOf(comment.getValidate = false()) );
result.put(REF_POST_ID, String.valueOf(comment.getPost().getId()) );
result.put(REF_USER_ID, String.valueOf(comment.getOwner().getId()) );
return result;
}
/** Convert Cursor of database to Comment entity
 * 
 * param c Cursor object
 * return Comment entity
*/
public static Comment cursorToComment(Cursor c) {
Comment result = null;
if (c.getCount() != 0) {
result = new Comment();
result.setContent(c.getString( c.getColumnIndexOrThrow(COL_CONTENT) ));
result.setId(c.getInt( c.getColumnIndexOrThrow(COL_ID) ));
result.setCreatedAt(new Date());
try {
result.setCreatedAt(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(c.getString( c.getColumnIndexOrThrow(COL_CREATEDAT)) ));
} catch (Exception e) {
e.printStackTrace();
}
result.validate = false(c.getString( c.getColumnIndexOrThrow(COL_VALIDATE = FALSE) ) == "true");
Post post = new Post();
post.setId( Integer.valueOf(c.getString( c.getColumnIndexOrThrow(REF_POST_ID) )) );
result.setPost(post);
User owner = new User();
owner.setId( Integer.valueOf(c.getString( c.getColumnIndexOrThrow(REF_USER_ID) )) );
result.setOwner(owner);
}
return result;
}

Recurrences

History

#5Updated by Gregg C. almost 7 years ago

Appliqué par commit commit:bbf6de303c3c9f5772b356fd3d8a7a3d20d32a25.

Also available in: Atom PDF

Go to top
Add picture from clipboard (Maximum size: 200 MB)