本文整理匯總了Java中org.jdom2.Element.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.setText方法的具體用法?Java Element.setText怎麽用?Java Element.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdom2.Element
的用法示例。
在下文中一共展示了Element.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMetadataFormats
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* for the server request ?verb=ListMetadataFormats this method build the xml section
*
* @return
*/
public Element createMetadataFormats() {
Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
if (Metadata.values().length == 0) {
return new ErrorCode().getNoMetadataFormats();
}
Element listMetadataFormats = new Element("ListMetadataFormats", xmlns);
for (Metadata m : Metadata.values()) {
// logger.trace("{}: {}", m.getMetadataPrefix(), DataManager.getInstance().getConfiguration().isMetadataFormatEnabled(m.name()));
if (m.isOaiSet() && DataManager.getInstance().getConfiguration().isMetadataFormatEnabled(m.name())) {
Element metadataFormat = new Element("metadataFormat", xmlns);
Element metadataPrefix = new Element("metadataPrefix", xmlns);
metadataPrefix.setText(m.getMetadataPrefix());
Element schema = new Element("schema", xmlns);
schema.setText(m.getSchema());
Element metadataNamespace = new Element("metadataNamespace", xmlns);
metadataNamespace.setText(m.getMetadataNamespace());
metadataFormat.addContent(metadataPrefix);
metadataFormat.addContent(schema);
metadataFormat.addContent(metadataNamespace);
listMetadataFormats.addContent(metadataFormat);
}
}
return listMetadataFormats;
}
示例2: createResumptionTokenAndElement
import org.jdom2.Element; //導入方法依賴的package包/類
/**
*
* @param totalHits
* @param cursor
* @param xmlns
* @param handler
* @return
*/
private Element createResumptionTokenAndElement(long totalHits, int cursor, Namespace xmlns, RequestHandler handler) {
long now = System.currentTimeMillis();
long time = now + expiration;
ResumptionToken token = new ResumptionToken("oai_" + System.currentTimeMillis(), totalHits, cursor, time, handler);
try {
saveToken(token);
} catch (IOException e) {
// do nothing
}
Element eleResumptionToken = new Element("resumptionToken", xmlns);
eleResumptionToken.setAttribute("expirationDate", Utils.convertDate(time));
eleResumptionToken.setAttribute("completeListSize", String.valueOf(totalHits));
eleResumptionToken.setAttribute("cursor", String.valueOf(cursor));
eleResumptionToken.setText(token.getTokenName());
return eleResumptionToken;
}
示例3: wrongSchema
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* @param response
* @param string
* @throws IOException
*/
private static void wrongSchema(HttpServletResponse response, String parameter) throws IOException {
Element searchRetrieveResponse = new Element("searchRetrieveResponse", SRU_NAMESPACE);
Element version = new Element("version", SRU_NAMESPACE);
version.setText("1.2");
searchRetrieveResponse.addContent(version);
Element diagnostic = new Element("diagnostic", SRU_NAMESPACE);
searchRetrieveResponse.addContent(diagnostic);
Element uri = new Element("uri", DIAG_NAMESPACE);
uri.setText("info:srw/diagnostic/1/66");
diagnostic.addContent(uri);
Element details = new Element("details", DIAG_NAMESPACE);
details.setText(" Unknown schema for retrieval");
diagnostic.addContent(details);
Element message = new Element("message", DIAG_NAMESPACE);
message.setText("Unknown schema for retrieval / " + parameter);
diagnostic.addContent(message);
Document doc = new Document();
doc.setRootElement(searchRetrieveResponse);
Format format = Format.getPrettyFormat();
format.setEncoding("utf-8");
XMLOutputter xmlOut = new XMLOutputter(format);
xmlOut.output(doc, response.getOutputStream());
}
示例4: generateSearchRetrieve
import org.jdom2.Element; //導入方法依賴的package包/類
/**
*
* @param parameter
* @param request
* @param solr
* @return
* @throws SolrServerException
*/
private static Element generateSearchRetrieve(SruRequestParameter parameter, HttpServletRequest request, SolrSearchIndex solr)
throws SolrServerException {
Element root = new Element("searchRetrieveResponse", SRU_NAMESPACE);
Element version = new Element("version", SRU_NAMESPACE);
version.setText(parameter.getVersion());
root.addContent(version);
String query = generateSearchQuery(parameter, request);
QueryResponse queryResponse = solr.search(query, parameter.getStartRecord() - 1, parameter.getStartRecord() - 1 + parameter
.getMaximumRecords(), null, null, null);
SolrDocumentList solrDocuments = queryResponse.getResults();
Element numberOfRecords = new Element("numberOfRecords", SRU_NAMESPACE);
if (solrDocuments == null || solrDocuments.isEmpty()) {
numberOfRecords.setText("0");
logger.debug("Searched for {}, found {} documents.", query, 0);
} else {
numberOfRecords.setText(String.valueOf(solrDocuments.size()));
logger.debug("Searched for {}, found {} documents.", query, solrDocuments.size());
}
root.addContent(numberOfRecords);
Element records = new Element("records", SRU_NAMESPACE);
root.addContent(records);
generateRecords(records, solrDocuments, parameter, request, solr);
generateEchoedSearchRetrieveRequest(root, solrDocuments, parameter);
return root;
}
示例5: missingArgument
import org.jdom2.Element; //導入方法依賴的package包/類
private static void missingArgument(HttpServletResponse response, String parameter) throws IOException {
Element searchRetrieveResponse = new Element("searchRetrieveResponse", SRU_NAMESPACE);
Element version = new Element("version", SRU_NAMESPACE);
version.setText("1.2");
searchRetrieveResponse.addContent(version);
Element diagnostic = new Element("diagnostic", SRU_NAMESPACE);
searchRetrieveResponse.addContent(diagnostic);
Element uri = new Element("uri", DIAG_NAMESPACE);
uri.setText("info:srw/diagnostic/1/7");
diagnostic.addContent(uri);
Element details = new Element("details", DIAG_NAMESPACE);
details.setText("Mandatory parameter not supplied");
diagnostic.addContent(details);
Element message = new Element("message", DIAG_NAMESPACE);
message.setText("Mandatory parameter not supplied / " + parameter);
diagnostic.addContent(message);
Document doc = new Document();
doc.setRootElement(searchRetrieveResponse);
Format format = Format.getPrettyFormat();
format.setEncoding("utf-8");
XMLOutputter xmlOut = new XMLOutputter(format);
xmlOut.output(doc, response.getOutputStream());
}
示例6: getNoRecordsMatch
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* query returns no hits
*
* @return
*/
public Element getNoRecordsMatch() {
Element error = new Element("error", xmlns);
error.setAttribute("code", "noRecordsMatch");
error.setText("The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list.");
return error;
}
示例7: getNoMetadataFormats
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* for given identifier the metadata format used in metadataPrefix is not provided
*
* @return
*/
public Element getNoMetadataFormats() {
Element error = new Element("error", xmlns);
error.setAttribute("code", "noMetadataFormats");
error.setText("There are no metadata formats available for the specified item.");
return error;
}
示例8: getIdentifyXML
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* for the server request ?verb=Identify this method build the xml section in the Identify element
*
* @return the identify Element for the xml tree
* @throws SolrServerException
*/
public Element getIdentifyXML() throws SolrServerException {
// TODO: optional parameter: compression is not implemented
// TODO: optional parameter: description is not implemented
Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
Map<String, String> identifyTags = DataManager.getInstance().getConfiguration().getIdentifyTags();
Element identify = new Element("Identify", xmlns);
Element repositoryName = new Element("repositoryName", xmlns);
repositoryName.setText(identifyTags.get("repositoryName"));
identify.addContent(repositoryName);
Element baseURL = new Element("baseURL", xmlns);
baseURL.setText(identifyTags.get("baseURL"));
identify.addContent(baseURL);
Element protocolVersion = new Element("protocolVersion", xmlns);
protocolVersion.setText(identifyTags.get("protocolVersion"));
identify.addContent(protocolVersion);
// TODO: protocol definition allow more than one email adress, change away from HashMap
Element adminEmail = new Element("adminEmail", xmlns);
adminEmail.setText(identifyTags.get("adminEmail")); //
identify.addContent(adminEmail);
Element earliestDatestamp = new Element("earliestDatestamp", xmlns);
earliestDatestamp.setText(solr.getEarliestRecordDatestamp());
identify.addContent(earliestDatestamp);
Element deletedRecord = new Element("deletedRecord", xmlns);
deletedRecord.setText(identifyTags.get("deletedRecord"));
identify.addContent(deletedRecord);
Element granularity = new Element("granularity", xmlns);
granularity.setText(identifyTags.get("granularity"));
identify.addContent(granularity);
return identify;
}
示例9: generateEpicurHeader
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* generates header for epicur format
*
* @param doc
* @param dateUpdated
* @return
*/
private static Element generateEpicurHeader(SolrDocument doc, long dateUpdated) {
Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
Element header = new Element("header", xmlns);
Element identifier = new Element("identifier", xmlns);
identifier.setText(DataManager.getInstance().getConfiguration().getOaiIdentifier().get("repositoryIdentifier") + (String) doc.getFieldValue(
"URN"));
header.addContent(identifier);
Element datestamp = new Element("datestamp", xmlns);
datestamp.setText(parseDate(dateUpdated));
header.addContent(datestamp);
// setSpec
List<String> setSpecFields = DataManager.getInstance().getConfiguration().getSetSpecFieldsForMetadataFormat(Metadata.epicur.name());
if (!setSpecFields.isEmpty()) {
for (String setSpecField : setSpecFields) {
if (doc.containsKey(setSpecField)) {
for (Object fieldValue : doc.getFieldValues(setSpecField)) {
// TODO translation
Element setSpec = new Element("setSpec", xmlns);
setSpec.setText((String) fieldValue);
header.addContent(setSpec);
}
}
}
}
// status="deleted"
if (doc.getFieldValues(SolrConstants.DATEDELETED) != null) {
header.setAttribute("status", "deleted");
}
return header;
}
示例10: generateEpicurPageHeader
import org.jdom2.Element; //導入方法依賴的package包/類
/**
*
* @param doc
* @param urn
* @param dateUpdated
* @return
*/
private static Element generateEpicurPageHeader(SolrDocument doc, String urn, long dateUpdated) {
Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
Element header = new Element("header", xmlns);
Element identifier = new Element("identifier", xmlns);
identifier.setText(DataManager.getInstance().getConfiguration().getOaiIdentifier().get("repositoryIdentifier") + urn);
header.addContent(identifier);
Element datestamp = new Element("datestamp", xmlns);
datestamp.setText(parseDate(dateUpdated));
header.addContent(datestamp);
// setSpec
List<String> setSpecFields = DataManager.getInstance().getConfiguration().getSetSpecFieldsForMetadataFormat(Metadata.epicur.name());
if (!setSpecFields.isEmpty()) {
for (String setSpecField : setSpecFields) {
if (doc.containsKey(setSpecField)) {
for (Object fieldValue : doc.getFieldValues(setSpecField)) {
// TODO translation
Element setSpec = new Element("setSpec", xmlns);
setSpec.setText((String) fieldValue);
header.addContent(setSpec);
}
}
}
}
// status="deleted"
if (doc.getFieldValues(SolrConstants.DATEDELETED) != null) {
header.setAttribute("status", "deleted");
}
return header;
}
示例11: getNoSetHierarchy
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* there are no sets in repository
*
* @return
*/
public Element getNoSetHierarchy() {
Element error = new Element("error", xmlns);
error.setAttribute("code", "noSetHierarchy");
error.setText("The repository does not support sets.");
return error;
}
示例12: getBadResumptionToken
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* resumptionToken is expired, invalid, not found
*
* @return
*/
public Element getBadResumptionToken() {
Element error = new Element("error", xmlns);
error.setAttribute("code", "badResumptionToken");
error.setText("The value of the resumptionToken argument is invalid or expired.");
return error;
}
示例13: getBadVerb
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* the verb argument is missing or has invalid value
*
* @return
*/
public Element getBadVerb() {
Element error = new Element("error", xmlns);
error.setAttribute("code", "badVerb");
error.setText("Value of the verb argument is not a legal OAI-PMH verb, the verb argument is missing, or the verb argument is repeated. ");
return error;
}
示例14: getCannotDisseminateFormat
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* The metadataPrefix argument has invalid value
*
* @return
*/
public Element getCannotDisseminateFormat() {
Element error = new Element("error", xmlns);
error.setAttribute("code", "cannotDisseminateFormat");
error.setText("The metadata format identified by the value given for the metadataPrefix argument is not supported by the item or by the repository.");
return error;
}
示例15: getIdDoesNotExist
import org.jdom2.Element; //導入方法依賴的package包/類
/**
* identifier does not exist
*
* @return
*/
public Element getIdDoesNotExist() {
Element error = new Element("error", xmlns);
error.setAttribute("code", "idDoesNotExist");
error.setText(" The value of the identifier argument is unknown or illegal in this repository.");
return error;
}