Changeset 7187
- Timestamp:
- 2004-04-06T09:25:35+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDivision.java
r6287 r7187 28 28 29 29 public static final String DIVISION_TYPE = "Division"; 30 public static final String DIVISION_TAG = "div"; 31 public static final String FPTR_TAG = "fptr"; 30 32 31 33 public METSDivision(String ID, String order, String orderLabel, String userLabel, String type) … … 256 258 } 257 259 260 /** 261 * Get the parent division name. Division identifiers 262 * concatenate the ancestor's names with intervening 263 * '.' characters. 264 * 265 * @return <code>String</code> the division name 266 */ 258 267 public static String getParentName(String divisionName) 259 268 { int at = divisionName.lastIndexOf('.'); … … 265 274 } 266 275 276 /** 277 * Get the top division name. 278 * 279 * @return <code>String</code> the division name 280 */ 267 281 public static String getTopDivisionName(String divisionName) 268 282 { int at = divisionName.indexOf('.'); … … 272 286 } 273 287 else 274 { 275 } 276 } 277 278 /** 279 * Write the METS file in an XML to a text-output sink 288 { return divisionName; 289 } 290 } 291 292 /** 293 * Write the METS file in an XML to a text-output sink. 280 294 * 281 295 * @param <code>PrintWriter</code> the destination of the output 282 296 */ 283 297 public boolean write(PrintWriter writer) 284 { String tag = XMLTools.getOpenTag("mets", "div"); 298 { // Get the main tag for the division 299 String tag = XMLTools.getOpenTag("mets", DIVISION_TAG); 285 300 tag = XMLTools.addAttribute(tag, "ID", this.ID.toString()); 286 301 tag = XMLTools.addAttribute(tag, "TYPE", this.type); … … 292 307 { tag = XMLTools.addAttribute(tag, "LABEL", this.userLabel); 293 308 } 309 310 // Add a metadata reference attribute 311 if (this.metadataRefs.size() > 0) 312 { String metaList = this.writeList(this.metadataRefs); 313 314 tag = XMLTools.addAttribute(tag, "DMDID", metaList); 315 } 316 317 // write the central tag 294 318 writer.println(tag); 295 319 296 320 // write the list of file pointers for this structural element 297 321 if (this.fileRefs.size() > 0) 298 { tag = XMLTools.getOpenTag("mets", "fptr"); 299 300 String fileList = this.writeList(this.fileRefs); 301 302 tag = XMLTools.addAttribute(tag, "FILEID", fileList); 303 304 tag = XMLTools.makeSingleton(tag); 305 writer.println(tag); 306 } 307 308 // ..and then the metadata - this is the same code at present, 309 // but is replicated here in case of future amendment. 310 if (this.metadataRefs.size() > 0) 311 { tag = XMLTools.getOpenTag("mets", "mptr"); 312 313 String metaList = this.writeList(this.metadataRefs); 314 tag = XMLTools.addAttribute(tag, "METAID", metaList); 315 tag = XMLTools.makeSingleton(tag); 316 writer.println(tag); 322 { String fileList = this.writeTagList("mets", "fptr", "FILEID", this.fileRefs); 323 324 writer.println(fileList); 317 325 } 318 326 … … 329 337 330 338 // close the div element 331 writer.println(XMLTools.getCloseTag("mets", "div"));339 writer.println(XMLTools.getCloseTag("mets", DIVISION_TAG)); 332 340 333 341 return true; 342 } 343 344 /** 345 * A convenience method for writing a <code>List</code> as a series of tags... 346 */ 347 private String writeTagList(String namespace, String tagname, 348 String attribute, List list) 349 { StringBuffer listString = new StringBuffer(); 350 351 Iterator iterator = list.iterator(); 352 while (iterator.hasNext()) 353 { String item = iterator.next().toString(); 354 355 String tag = XMLTools.getOpenTag(namespace, tagname); 356 tag = XMLTools.addAttribute(tag, attribute, item); 357 tag = XMLTools.makeSingleton(tag); 358 359 listString.append(tag); 360 } 361 return listString.toString(); 334 362 } 335 363 … … 343 371 while (iterator.hasNext()) 344 372 { String item = iterator.next().toString(); 345 if (listString.length() > 0) 346 { listString.append(" "); 347 } 373 374 if (listString.length() > 0) { 375 listString.append(" "); 376 } 377 348 378 listString.append(item); 349 379 }
Note:
See TracChangeset
for help on using the changeset viewer.