Last active
August 29, 2015 14:10
-
-
Save h3xxx/a86e6599a30e77fa0091 to your computer and use it in GitHub Desktop.
Template object class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package PACKAGE; | |
import PACKAGE...; | |
/** | |
* DOCUMENT | |
* | |
* @author $Author: h3XXx $ | |
* @version $Revision: 100000 $ | |
*/ | |
public class OBJECTClass extends OBJECTClassGeneric | |
{ | |
//~ Static fields/initializers ******************************************************************************************************************* | |
public static final String _title = "OBJECT_CLASS"; | |
public static final String _version = "$Rev: 100000 $"; | |
public static final String _sheet_head_1 = "OBJECT_CLASS"; | |
public static final String FIELD01 = "ID"; | |
public static final String FIELD02 = "Param 1"; //ID | |
public static final String FIELD03 = "Param 2"; //NAME | |
public static final String[] _paramTagName = { "OBJECTClass" }; | |
public static final String _BASEREL_OBJECT_CLASS = "OBJECT_CLASS"; | |
public static final COLHEAD[] _row_head = | |
{ | |
new COLHEAD(FIELD01, OPTIONAL, _CSV_NA, _XML_NA), | |
new COLHEAD(FIELD02, MANDATORY, _CSV_NA, "PARAM_1"), | |
new COLHEAD(FIELD03, OPTIONAL, _CSV_NA, "PARAM_2"), | |
}; | |
public static final int _MIN_ID = 1; | |
public static final int _MAX_ID = 100; | |
//~ Instance fields ****************************************************************************************************************************** | |
public String[] _relations = new String[]{ _BASEREL_OBJECT_CLASS }; | |
public int _id = _PARAMETER_NOT_DEFINED; | |
public String _param_1 = ""; | |
public String _param_2 = ""; | |
public String pattern = "[0-9*#abcABC]*"; | |
public int _param_2_len = _PARAMETER_NOT_DEFINED; | |
//~ Constructors ********************************************************************************************************************************* | |
public OBJECTClass(final PrintWriter out, final ReleaseInfo info, final ReleaseInfo sheet, final HSSFWorkbook w, final boolean first) | |
{ | |
super(out, info, sheet, w, 2, 1); | |
_sheet_head = _sheet_head_1; | |
_PACKAGE = _PACKAGE_GROUP; | |
_GUI_MENU = "Group -> Subgroup -> OBJECT Class"; | |
if((_sheet == null) && (_workbook != null)) | |
{ | |
_sheet = XLSHelper.getSheet(_workbook, _sheet_head, this); | |
} | |
_paramTagNames_orig = _paramTagName; | |
_relations_orig = _relations; | |
_row_head_orig = _row_head; | |
init(_sheet_head, _row_head_orig, first); | |
} | |
//~ Methods ************************************************************************************************************************************** | |
public String getTitle() | |
{ | |
return OBJECTClass._title; | |
} | |
public String getVersion() | |
{ | |
return OBJECTClass._version; | |
} | |
public boolean readRow(final TransformObject obj, final int currentRow) | |
{ | |
if(checkRelease(10, 10, 00) && !checkRelease(10, 20, 00)) | |
{ | |
return false; | |
} | |
HSSFRow row = _sheet.getRow(currentRow); | |
if((row == null) || checkEmptyRow(row, currentRow + 1)) | |
{ | |
return false; | |
} | |
_phase = getPhase(obj, row, FIELD01); | |
_id = getIntValue(row, FIELD01, new int[]{ _MIN_ID, _MAX_ID }, _id); | |
_param_1 = getValue(row, FIELD02); | |
_param_2 = getValue(row, FIELD03); | |
_param_2_len = Util.hasContent(_param_2) ? _param_2.length() : 0; | |
return true; | |
} | |
public int writeDat(final TransformObject obj, final int cnt, final int currentRow) | |
{ | |
if(_releaseInfo.checkRelease(10, 10, 00) && !_releaseInfo.checkRelease(10, 20, 00)) | |
{ | |
return _SUCCESS; | |
} | |
if(!Util.hasContent(_param_1) && !Util.hasContent(_param_2)) | |
{ | |
return _SUCCESS; | |
} | |
Element xml_obj = obj.object_toXML(_BASEREL_OBJECT_CLASS, cnt + "", obj._BASEOBJECT); | |
if(Util.hasContent(_param_1)) | |
{ | |
obj.parameter_toXML("param_1", _param_1, xml_obj); | |
} | |
obj.parameter_toXML("param_2", _gsm_scf_address, xml_obj); | |
obj.parameter_toXML("param_2_len", _gsm_scf_address_len, xml_obj); | |
obj.write_Seq0(xml_obj, "filler", 2); | |
return _GLSUCCESS; | |
} | |
public int writeXml(final TransformObject obj, final String tag, final int cnt, final int currentRow) | |
{ | |
if(checkRelease(10, 10, 00) && !checkRelease(10, 20, 00)) | |
{ | |
return _GLSUCCESS; | |
} | |
Element xml_request = obj.writeRequest(); | |
Element xml_OBJECTClass = obj.objectToXMLTag(tag, "", xml_request); | |
if(xml_OBJECTClass == null) | |
{ | |
return _GLSUCCESS; | |
} | |
obj.parameterToXMLTag("ID", _id, xml_OBJECTClass); | |
obj.parameterToXMLTag("PARAM_1", _param_1, xml_OBJECTClass); | |
Element xml_record = obj.objectToXMLTag("Record", "", xml_OBJECTClass); | |
obj.parameterToXMLTag("PARAM_2", _param_2, xml_record); | |
obj.parameterToXMLTag("PARAM_2_LEN", _param_2_len, xml_record); | |
return _GLSUCCESS; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment