Back to project page androidata.
The source code is released under:
Apache License
If you think the Android project androidata listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.stanidesis.androidata.column; //w w w. ja v a2 s . c o m /** * Created by Stanley Idesis on 8/15/14. */ public abstract class Column<ObjectType> { public enum StorageType { DOUBLE("DOUBLE"), TEXT("TEXT"), INTEGER("INTEGER"); private String mLiteral; StorageType(String literal) { mLiteral = literal; } public String getLiteral() { return mLiteral; } } private final String mName; private final StorageType mStorageType; private final ObjectType mDefaultValue; private final boolean mIsPrimaryKey; private final boolean mAutoIncrement; public Column(String name, StorageType storageType, ObjectType defaultValue) { this(name, storageType, defaultValue, false, false); } public Column(String name, StorageType storageType, ObjectType defaultValue, boolean isPrimaryKey, boolean autoIncrement) { mName = name; mStorageType = storageType; mDefaultValue = defaultValue; mIsPrimaryKey = isPrimaryKey; mAutoIncrement = autoIncrement; } public String getName() { return mName; } public StorageType getType() { return mStorageType; } public String getSQLCreateStatement() { StringBuilder builder = new StringBuilder(mName); builder.append(" ").append(getType().getLiteral()); if (mIsPrimaryKey) { builder.append(" PRIMARY KEY"); } if (mAutoIncrement) { builder.append(" AUTOINCREMENT"); } if (mDefaultValue != null) { builder.append(" DEFAULT ").append(String.valueOf(mDefaultValue)); } return builder.toString(); } }