|
From: Johan T. <jt...@us...> - 2006-12-02 22:29:01
|
Update of /cvsroot/vienti/vienti/source/se/biobanksregistersyd/vienti/datasources In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv7959/source/se/biobanksregistersyd/vienti/datasources Modified Files: DsRandomdata_RBBR.java Log Message: Code style fixes. Index: DsRandomdata_RBBR.java =================================================================== RCS file: /cvsroot/vienti/vienti/source/se/biobanksregistersyd/vienti/datasources/DsRandomdata_RBBR.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- DsRandomdata_RBBR.java 20 Jun 2006 14:24:29 -0000 1.15 +++ DsRandomdata_RBBR.java 2 Dec 2006 22:28:59 -0000 1.16 @@ -24,9 +24,12 @@ ** liable for any use that may be made of the information contained herein. ** ** $Log$ + ** Revision 1.16 2006/12/02 22:28:59 jtorin + ** Code style fixes. + ** ** Revision 1.15 2006/06/20 14:24:29 amijdema - ** Removed the inline class CurrentClassGetter. Now they use CurrentContext.java - ** in its place. + ** Removed the inline class CurrentClassGetter. Now they use + ** CurrentContext.java in its place. ** ** Revision 1.14 2006/06/19 16:17:19 jtorin ** Reformat code according to style. Mega Commiten 2. @@ -105,17 +108,19 @@ * @author johant */ public class DsRandomdata_RBBR extends DsRandomdata { - /** Current classname. + /** Current classname. * "se.biobanksregistersyd.vienti.datasource.DsRandomdata_RBBR" */ - private static final String CLASSNAME = CurrentContext.getCurrentClassName(); - - /** log4j. */ + private static final String CLASSNAME + = CurrentContext.getCurrentClassName(); + + /** log4j. */ private static Logger logger = Logger.getLogger(CLASSNAME); /** * The name of the class that this Datasource is supposed to work with. */ - private final String companionDatafile = "se.biobanksregistersyd.vienti.datafiles.DfXML_RBBR"; + private final String companionDatafile + = "se.biobanksregistersyd.vienti.datafiles.DfXML_RBBR"; /** * Creates a <code>DsRandomdata_RBBR</code> object and loads neccesary @@ -209,10 +214,7 @@ randomDate((long) (x * 1.6)))); dataset.put("base:arrivalDate", new String( randomDate((long) (x * 1.61)))); - dataset.put("rbbr:sampleOrderingUnit", new String("MAKAHJ")); // Get - // syntax - // for - // this + dataset.put("rbbr:sampleOrderingUnit", new String("MAKAHJ")); dataset.put("rbbr:sampleOrderingUnitType", new String( "rbbr:sampleOrderingUnitMG")); dataset.put("rbbr:sampleOrderer", new String(randomName())); @@ -294,27 +296,52 @@ df.close(); } + /** + * Creates a pseudo person number from a date in numerical format. + * + * @param x a <code>long</code> with a date in milliseconds since the + * start of the epoch. + * @return a <code>String</code> with a pseudo person number. + */ private String randomPno(final long x) { - Format formatter; Date randomDate = new Date(x); - formatter = new SimpleDateFormat("yyyyMMdd" + "9999"); + Format formatter = new SimpleDateFormat("yyyyMMdd" + "9999"); return formatter.format(randomDate); } + /** + * Formats a date as a <code>String</code> from its numerical format. + * + * @param x a <code>long</code> with a date in milliseconds since the + * start of the epoch. + * @return a <code>String</code> with the date as a <code>String</code>. + */ private String randomDate(final long x) { Date randomDate = new Date((long) (x)); - Format formatter; - formatter = new SimpleDateFormat("yyyy-MM-dd"); + Format formatter = new SimpleDateFormat("yyyy-MM-dd"); return formatter.format(randomDate); } + /** + * Creates an artifical sample id. + * + * @param x a <code>long</code> with a date in milliseconds since the + * start of the epoch. + * @param i a <code>int</code> with a serial number for the id. + * @return a <code>String</code> with a created sample id. + */ private String randomMainSampleId(final long x, final int i) { Date randomDate = new Date((long) (x)); - Format formatter; - formatter = new SimpleDateFormat("yyyy"); + Format formatter = new SimpleDateFormat("yyyy"); return formatter.format(randomDate) + "-" + i; } + /** + * Builds an pseudo artifical person name. + * + * @return a <code>String</code> with a name that a person + * could have. + */ private String randomName() { String[] fName = { "Emma", "Agnes", "Maja", "Alexandra", "Julia", "Alicia", "Ida", "Alma", "Linnéa", "Alva", "Elin" }; @@ -327,6 +354,11 @@ + lName[(int) (Math.random() * fName.length)]; } + /** + * Returns a random vital status. + * + * @return a <code>String</code> with a random vital status. + */ private String randomVitalStatus() { if (((int) (Math.random() * 2)) > 0) { return "ALIVE"; @@ -335,24 +367,41 @@ } } + /** + * Returns a random preparation result. + * + * @return a <code>String</code> with a random preparation result. + */ private String randomPreparationResult() { String[] preparationResult = { "WHOLE_BLOOD", "PLASMA", "SERUM", "DNA", "RNA", "PROTEIN", "LIPID", "CARBOHYDRATE", "EDTA-PLASMA", "HEPARIN-PLASMA", "CITRATED-PLASMA", "LIQUOR", "UNSPECIFIED" }; - return preparationResult[(int) (Math.random() * preparationResult.length)]; + return preparationResult[(int) (Math.random() + * preparationResult.length)]; } + /** + * Returns a random storage form. + * + * @return a <code>String</code> with a random storage form. + */ private String randomStorageForm() { String[] storageForm = { "FREEZED", "FREEZE-DRIED", "SPECIMEN_SLIDE", "PARAFFIN_BLOCK" }; return storageForm[(int) (Math.random() * storageForm.length)]; } + /** + * Returns a random storage temperature. + * + * @return a <code>String</code> with a random storage temperature. + */ private String randomStorageTemperature() { String[] storageTemperature = { "ROOM_TEMPERATURE", "COLD_ROOM", "FREEZER_-20DEGC", "FREEZER_-70DEGC", "FREEZER_-140DEGC", "FREEZE-DRIED", "LIQUID_NITROGEN" }; - return storageTemperature[(int) (Math.random() * storageTemperature.length)]; + return storageTemperature[(int) (Math.random() + * storageTemperature.length)]; } /** |