Revision 1491
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/MetaCatUtil.java | ||
---|---|---|
234 | 234 |
} |
235 | 235 |
} |
236 | 236 |
|
237 |
/** |
|
238 |
* Utility method to print debugging messages |
|
239 |
* |
|
240 |
* @param flag an integer indicating the message number |
|
241 |
*/ |
|
242 |
public static void debugMessage(int flag) { |
|
243 |
if (debug) { |
|
244 |
System.err.println("DEBUG FLAG: " + flag); |
|
245 |
} |
|
246 |
} |
|
247 |
|
|
248 |
/** |
|
249 |
* Utility method to print debugging messages |
|
250 |
* |
|
251 |
* @param flag an integer indicating the message number |
|
252 |
*/ |
|
253 |
public static void debugMessage(String msg) { |
|
254 |
if (debug) { |
|
255 |
System.err.println(msg); |
|
256 |
} |
|
257 |
} |
|
258 | 237 |
|
259 |
public static void debug(String msg) |
|
260 |
{ |
|
261 |
if(debug) |
|
262 |
{ |
|
263 |
System.err.println(msg); |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
|
|
268 |
|
|
269 | 238 |
public static Vector getOptionList(String optiontext) |
270 | 239 |
{ |
271 | 240 |
Vector options = new Vector(); |
... | ... | |
490 | 459 |
* Method to get docidwithrev from eml2 inline data id |
491 | 460 |
* The eml inline data id would look like eml.200.2.3 |
492 | 461 |
*/ |
493 |
public static String getDocIdWithRevFromInlineDataID(String inlineDataID) |
|
462 |
public static String getDocIdWithoutRevFromInlineDataID(String inlineDataID)
|
|
494 | 463 |
{ |
495 |
String docidWithRev = null; |
|
464 |
String docidWithoutRev = null; |
|
465 |
if ( inlineDataID == null) |
|
466 |
{ |
|
467 |
return docidWithoutRev; |
|
468 |
} |
|
496 | 469 |
String seperator = MetaCatUtil.getOption("accNumSeparator"); |
497 |
int index = inlineDataID.lastIndexOf(seperator); |
|
498 |
docidWithRev = inlineDataID.substring(0, index); |
|
499 |
MetaCatUtil.debugMessage("docid with rev from inlinedata id: " + |
|
500 |
docidWithRev, 25); |
|
501 |
return docidWithRev; |
|
470 |
char charSeperator = seperator.charAt(0); |
|
471 |
int targetNumberOfSeperator = 2;// we want to know his index |
|
472 |
int numberOfSeperator = 0; |
|
473 |
for (int i = 0; i< inlineDataID.length(); i++) |
|
474 |
{ |
|
475 |
// meet seperator, increase number of seperator |
|
476 |
if (inlineDataID.charAt(i) == charSeperator) |
|
477 |
{ |
|
478 |
numberOfSeperator++; |
|
479 |
} |
|
480 |
// if number of seperator reach the target one, record the index(i) |
|
481 |
// and get substring and terminate the loop |
|
482 |
if ( numberOfSeperator == targetNumberOfSeperator) |
|
483 |
{ |
|
484 |
docidWithoutRev = inlineDataID.substring(0, i); |
|
485 |
break; |
|
486 |
} |
|
487 |
} |
|
488 |
|
|
489 |
MetaCatUtil.debugMessage("Docid without rev from inlinedata id: " + |
|
490 |
docidWithoutRev, 35); |
|
491 |
return docidWithoutRev; |
|
502 | 492 |
|
503 | 493 |
} |
504 | 494 |
|
Also available in: Unified diff
Revise the method to get docid withoutRevision from inlinedataid.