Changeset 2464 for SRUClient/trunk
- Timestamp:
- 01/15/13 11:03:03 (11 years ago)
- Location:
- SRUClient/trunk/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFCSRecordData.java
r2305 r2464 1 1 /** 2 * This software is copyright (c) 201 1by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 23 23 24 24 /** 25 * A record data implementation for CLARIN 25 * A record data implementation for CLARIN-FCS. 26 26 */ 27 27 public final class ClarinFCSRecordData implements 28 28 SRURecordData { 29 29 /** 30 * The record schema for CLARIN 30 * The record schema for CLARIN-FCS records. 31 31 */ 32 32 public static final String RECORD_SCHEMA = "http://clarin.eu/fcs/1.0"; … … 53 53 54 54 /** 55 * Get the CLARIN 55 * Get the CLARIN-FCS record resource. 56 56 * 57 57 * @return a {@link Resource} object -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFCSRecordParser.java
r2402 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 31 31 32 32 /** 33 * A record parse to parse records conforming to CLARIN 33 * A record parse to parse records conforming to CLARIN-FCS specification. 34 34 */ 35 35 public class ClarinFCSRecordParser implements SRURecordDataParser { … … 89 89 String pid = XmlStreamReaderUtils.readAttributeValue(reader, null, "pid"); 90 90 String ref = XmlStreamReaderUtils.readAttributeValue(reader, null, "ref"); 91 String type = XmlStreamReaderUtils.readAttributeValue(reader, null, "mime-type"); 92 if ((type == null) || type.isEmpty()) { 93 logger.debug("element <DataView> does not carry attribute " + 94 "'mime-type'; trying attribute 'type' instead"); 95 type = XmlStreamReaderUtils.readAttributeValue(reader, null, "type"); 96 if (type != null) { 97 logger.warn("attribute 'type' is deprecated for element " + 98 "<DataView>; please use 'mime-type' attribute"); 99 } 100 } 91 String type = XmlStreamReaderUtils.readAttributeValue(reader, null, "type"); 101 92 if ((type == null) || type.isEmpty()) { 102 93 throw new SRUClientException("element <DataView> needs a " 103 + "non-empty ' mime-type' (or 'type')attribute");94 + "non-empty 'type' attribute"); 104 95 } 105 96 -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataView.java
r2394 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 18 18 19 19 /** 20 * Base class for DataView implementations according to the CLARIN 20 * Base class for DataView implementations according to the CLARIN-FCS record 21 21 * schema. 22 22 */ 23 23 public abstract class DataView { 24 private final String mimetype;24 private final String type; 25 25 private final String pid; 26 26 private final String ref; … … 30 30 * Constructor. 31 31 * 32 * @param mimetype33 * the MIME type of this dataview32 * @param type 33 * the MIME type of this DataView 34 34 * @param pid 35 35 * a persistent identifier or <code>null</code> … … 40 40 * 41 41 */ 42 protected DataView(String mimetype, String pid, String ref) {43 if ( mimetype == null) {44 throw new NullPointerException(" mimetype == null");42 protected DataView(String type, String pid, String ref) { 43 if (type == null) { 44 throw new NullPointerException("type == null"); 45 45 } 46 this. mimetype = mimetype;47 this.pid = ((pid != null) && !pid.isEmpty()) ? pid : null;48 this.ref = ((ref != null) && !ref.isEmpty()) ? ref : null;46 this.type = type; 47 this.pid = ((pid != null) && !pid.isEmpty()) ? pid : null; 48 this.ref = ((ref != null) && !ref.isEmpty()) ? ref : null; 49 49 } 50 50 … … 56 56 */ 57 57 public String getMimeType() { 58 return mimetype;58 return type; 59 59 } 60 60 … … 63 63 * Convenience method to check if this DataView is of a certain MIME type. 64 64 * 65 * @param mimetype65 * @param type 66 66 * the MIME type to test against 67 67 * @return <code>true</code> if the DataView is in the supplied MIME type, … … 70 70 * if any required arguments are not supplied 71 71 */ 72 public boolean isMimeType(String mimetype) {73 if ( mimetype == null) {72 public boolean isMimeType(String type) { 73 if (type == null) { 74 74 throw new NullPointerException("mimetype == null"); 75 75 } 76 return (this. mimetype.equals(mimetype));76 return (this.type.equals(type)); 77 77 } 78 78 -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewGenericDOM.java
r2394 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 20 20 21 21 22 /** 23 * A generic DataView implementation that stores the content as a DOM document. 24 */ 22 25 public class DataViewGenericDOM extends DataView { 23 26 private final Document document; 24 27 25 28 26 protected DataViewGenericDOM(String mimetype, String pid, String ref,29 protected DataViewGenericDOM(String type, String pid, String ref, 27 30 Document document) { 28 super( mimetype, pid, ref);31 super(type, pid, ref); 29 32 this.document = document; 30 33 } 31 34 32 35 36 /** 37 * Get the DataView content. 38 * 39 * @return the DataView content as DOM document. 40 */ 33 41 public Document getDocument() { 34 42 return document; -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewGenericString.java
r2402 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 17 17 package eu.clarin.sru.fcs; 18 18 19 /** 20 * A generic DataView implementation that stores the content as a String. 21 */ 19 22 public class DataViewGenericString extends DataView { 20 23 private final String content; 21 24 22 25 23 protected DataViewGenericString(String mimetype, String pid, String ref,26 protected DataViewGenericString(String type, String pid, String ref, 24 27 String content) { 25 super( mimetype, pid, ref);28 super(type, pid, ref); 26 29 this.content = content; 27 30 } 28 31 29 32 33 /** 34 * Get DataView content. 35 * 36 * @return the DataView content as String. 37 */ 30 38 public String getContent() { 31 39 return content; -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewKWIC.java
r2394 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 18 18 19 19 /** 20 * A CLARIN 20 * A CLARIN-FCS KWIC DataView. 21 21 */ 22 22 public final class DataViewKWIC extends DataView { 23 23 /** 24 * The MIME type for CLARIN FCS KWIC dataviews.24 * The MIME type for CLARIN-FCS KWIC data views. 25 25 */ 26 public static final String MIMETYPE = "application/x-clarin-fcs-kwic+xml";26 public static final String TYPE = "application/x-clarin-fcs-kwic+xml"; 27 27 private final String left; 28 28 private final String keyword; … … 46 46 DataViewKWIC(String pid, String ref, String left, String keyword, 47 47 String right) { 48 super( MIMETYPE, pid, ref);48 super(TYPE, pid, ref); 49 49 this.left = (left != null) ? left : ""; 50 50 this.keyword = (keyword != null) ? keyword : ""; -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewParser.java
r2394 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 25 25 /** 26 26 * Base class for implementing parsers for parsing a specific DataView in a 27 * CLARIN 27 * CLARIN-FCS record. 28 28 * <p>If multiple record parsers support a certain type, the one 29 29 * with the highest priority is selected.</p> -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewParserGenericDOM.java
r2401 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewParserGenericString.java
r2402 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewParserKWIC.java
r2394 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 34 34 @Override 35 35 public boolean acceptType(String type) { 36 return DataViewKWIC. MIMETYPE.equals(type) ||36 return DataViewKWIC.TYPE.equals(type) || 37 37 KWIC_LEGACY_TYPE.equals(type); 38 38 } … … 47 47 String ref) throws XMLStreamException, SRUClientException { 48 48 if (KWIC_LEGACY_TYPE.equals(type)) { 49 logger.warn("type '" + KWIC_LEGACY_TYPE + "' is deprecteded for a KWIC <DataView>, please use '" + DataViewKWIC. MIMETYPE + "' instead");49 logger.warn("type '" + KWIC_LEGACY_TYPE + "' is deprecteded for a KWIC <DataView>, please use '" + DataViewKWIC.TYPE + "' instead"); 50 50 } 51 51 String left = null; -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/Resource.java
r2394 r2464 1 1 /** 2 * This software is copyright (c) 201 1-2012by2 * This software is copyright (c) 2012-2013 by 3 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 4 * This is free software. You can redistribute it … … 21 21 22 22 /** 23 * A CLARIN 23 * A CLARIN-FCS resource 24 24 */ 25 25 public class Resource { 26 26 /** 27 * A CLARIN 27 * A CLARIN-FCS resource fragment 28 28 */ 29 29 public final static class ResourceFragment { … … 68 68 /** 69 69 * Convenience method to check if this resource fragment has any 70 * data views.70 * data views. 71 71 * 72 * @return <code>true</code> if this resource fragment has data views,72 * @return <code>true</code> if this resource fragment has data views, 73 73 * <code>false</code> otherwise 74 74 */ … … 79 79 80 80 /** 81 * Get the list of data view objects for this this resource fragment.81 * Get the list of data view objects for this this resource fragment. 82 82 * 83 83 * @return a list of {@link DataView} objects or <code>null</code>, -
SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestUtils.java
r2402 r2464 185 185 s, 186 186 view.getContent() }); 187 } else if (dataview.isMimeType(DataViewKWIC. MIMETYPE)) {187 } else if (dataview.isMimeType(DataViewKWIC.TYPE)) { 188 188 final DataViewKWIC kw = (DataViewKWIC) dataview; 189 189 logger.info("{}DataView: {} / {} / {}",
Note: See TracChangeset
for help on using the changeset viewer.