本文整理汇总了Java中com.marklogic.xcc.types.ValueType类的典型用法代码示例。如果您正苦于以下问题:Java ValueType类的具体用法?Java ValueType怎么用?Java ValueType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValueType类属于com.marklogic.xcc.types包,在下文中一共展示了ValueType类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructTransformOption
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
private static XdmValue constructTransformOption(Configuration conf,
String functionParam, String functionNs) {
HashMap<String, String> transMap = new HashMap<>();
String modules = conf.get(ConfigConstants.CONF_INPUT_MODULES_DATABASE);
String modulesRoot = conf.get(ConfigConstants.CONF_INPUT_MODULES_ROOT);
if (modules != null) {
transMap.put("modules", modules);
}
if (modulesRoot != null) {
transMap.put("modules-root", modulesRoot);
}
if (!"".equals(functionNs)) {
transMap.put("transform-namespace", functionNs);
}
if (!"".equals(functionParam)) {
transMap.put("transform-param", functionParam);
}
if (transMap.isEmpty()) {
return ValueFactory.newJSNull();
} else {
ObjectNode node = mapToNode(transMap);
return ValueFactory.newValue(ValueType.JS_OBJECT, node);
}
}
示例2: initMetadataMap
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
private void initMetadataMap() throws IOException {
while (result.hasNext()) {
ResultItem item = result.next();
String type = null;
if (item != null && item.getItemType() == ValueType.XS_STRING) {
type = item.asString();
} else {
throw new IOException("incorrect format:" + item.getItem()
+ "\n" + result.asString());
}
if ("META".equals(type)) {
DocumentMetadata metadata = new DocumentMetadata();
String uri = parseMetadata(metadata);
metadataMap.put(uri, metadata);
} else if ("EOM".equals(type)) {
//end of metadata
return;
} else {
throw new IOException("incorrect type");
}
}
}
示例3: write
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
@Override
public void write(DocumentURI uri, MarkLogicNode record)
throws IOException, InterruptedException {
// initialize recordString
String recordString = record == null ? "()" : record.toString();
// execute query
Session session = getSession();
try {
AdhocQuery request = session.newAdhocQuery(query);
request.setNewStringVariable(DOCURI_VARIABLE_NAME,
InternalUtilities.unparse(uri.getUri()));
request.setNewVariable(NODE_VARIABLE_NAME, ValueType.ELEMENT,
recordString);
session.submitRequest(request);
commitIfNecessary();
} catch (RequestException e) {
LOG.error(e);
LOG.error(query);
throw new IOException(e);
}
}
示例4: write
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
@Override
public void write(NodePath path, MarkLogicNode record)
throws IOException, InterruptedException {
if (record == null || record.get() == null) {
throw new UnsupportedOperationException("Record node is null.");
} else if (record.get().getNodeType() != Node.ELEMENT_NODE) {
throw new UnsupportedOperationException("Unsupported node type: " +
record.get().getNodeType());
}
String recordString = record.toString();
if (LOG.isDebugEnabled()) {
LOG.debug(query);
}
Session session = getSession();
try {
AdhocQuery request = session.newAdhocQuery(query);
request.setNewStringVariable(PATH_VARIABLE_NAME, path.getFullPath());
request.setNewVariable(NODE_VARIABLE_NAME, ValueType.ELEMENT,
recordString);
if (LOG.isDebugEnabled()) {
LOG.debug("path: " + path.getFullPath());
LOG.debug("node: " + recordString);
}
session.submitRequest(request);
commitIfNecessary();
} catch (RequestException e) {
LOG.error(e);
LOG.error(query);
throw new IOException(e);
}
}
示例5: set
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
public void set(ResultItem item){
try {
if (item.getValueType() == ValueType.DOCUMENT) {
content = item.asString().getBytes("UTF-8");
contentType = ContentType.XML;
} else if (item.getValueType() == ValueType.ELEMENT) {
content = item.asString().getBytes("UTF-8");
contentType = ContentType.XML;
} else if (item.getValueType() == ValueType.TEXT) {
content = item.asString().getBytes("UTF-8");
contentType = ContentType.TEXT;
} else if (item.getValueType() == ValueType.BINARY) {
if (item.isCached()) {
content = ((XdmBinary) item.getItem()).asBinaryData();
} else {
is = item.asInputStream();
}
contentType = ContentType.BINARY;
} else if (item.getValueType() == ValueType.ARRAY_NODE ||
item.getValueType() == ValueType.BOOLEAN_NODE ||
item.getValueType() == ValueType.NULL_NODE ||
item.getValueType() == ValueType.NUMBER_NODE ||
item.getValueType() == ValueType.OBJECT_NODE) {
content = item.asString().getBytes("UTF-8");
contentType = ContentType.JSON;
} else {
contentType = ContentType.UNKNOWN;
}
} catch (UnsupportedEncodingException e) {
LOG.error(e);
}
}
示例6: KeyValueWriter
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
public KeyValueWriter(Configuration conf, String host) {
super(conf, host);
String keyDataType = conf.get(OUTPUT_KEY_TYPE, "xs:string");
keyType = ValueType.valueOf(keyDataType);
String valueDataType = conf.get(OUTPUT_VALUE_TYPE, "xs:string");
valueType = ValueType.valueOf(valueDataType);
statement = conf.get(OUTPUT_QUERY);
queryLanguage = conf.get(OUTPUT_QUERY_LANGUAGE);
}
示例7: newValue
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
/**
* Create new XdmValue from value type and Writables.
*
*/
public static XdmValue newValue(ValueType valueType, Object value) {
if (value instanceof Text) {
return ValueFactory.newValue(valueType, ((Text)value).toString());
} else if (value instanceof BytesWritable) {
return ValueFactory.newValue(valueType, ((BytesWritable)value).getBytes());
} else if (value instanceof IntWritable) {
return ValueFactory.newValue(valueType, ((IntWritable)value).get());
} else if (value instanceof LongWritable) {
return ValueFactory.newValue(valueType, ((LongWritable)value).get());
} else if (value instanceof VIntWritable) {
return ValueFactory.newValue(valueType, ((VIntWritable)value).get());
} else if (value instanceof VLongWritable) {
return ValueFactory.newValue(valueType, ((VLongWritable)value).get());
} else if (value instanceof BooleanWritable) {
return ValueFactory.newValue(valueType, ((BooleanWritable)value).get());
} else if (value instanceof FloatWritable) {
return ValueFactory.newValue(valueType, ((FloatWritable)value).get());
} else if (value instanceof DoubleWritable) {
return ValueFactory.newValue(valueType, ((DoubleWritable)value).get());
} else if (value instanceof MarkLogicNode) {
return ValueFactory.newValue(valueType, ((MarkLogicNode)value).get());
} else {
throw new UnsupportedOperationException("Value " +
value.getClass().getName() + " is unsupported.");
}
}
示例8: bindParams
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
private void bindParams(Map<String, Parameter> params, Request request) { //throws RequestException {
for (Map.Entry<String, Parameter> e: params.entrySet()) {
XName name = new XName(e.getKey());
XdmValue value;
switch (e.getValue().getType()) {
case "boolean": {
value = ValueFactory.newXSBoolean(new Boolean(e.getValue().getName()));
break;
}
case "byte":
case "int":
case "long":
case "short": {
value = ValueFactory.newXSInteger(new Integer(e.getValue().getName()));
break;
}
case "double": {
value = ValueFactory.newValue(ValueType.XS_DOUBLE, new Double(e.getValue().getName()));
break;
}
case "float": {
value = ValueFactory.newValue(ValueType.XS_FLOAT, new Float(e.getValue().getName()));
break;
}
default:
value = ValueFactory.newXSString(e.getValue().getName());
}
request.setVariable(ValueFactory.newVariable(name, value));
}
}
示例9: setDocumentProperties
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
/**
*
* @param uri
* uri of the document whose property is to be set
* @param xmlString
* property in xml string
* @param forestId
* @throws RequestException
*/
protected static boolean setDocumentProperties(String uri,
String xmlString, String permString, String collString, String quality,
Map<String, String> meta, Session s) {
String query = XQUERY_VERSION_1_0_ML
+ "declare variable $URI as xs:string external;\n"
+ "declare variable $XML-STRING as xs:string external;\n"
+ "declare variable $PERM-STRING as xs:string external;\n"
+ "declare variable $COLL-STRING as xs:string external;\n"
+ "declare variable $QUALITY-STRING as xs:string external;\n"
+ (meta == null ?
"" : "declare variable $META as map:map external;\n")
+ "xdmp:document-set-properties($URI,\n"
+ " xdmp:unquote($XML-STRING)/prop:properties/node() )\n"
+ ", if('' eq ($PERM-STRING)) then () else \n"
+ "xdmp:document-set-permissions($URI, \n"
+ "xdmp:unquote($PERM-STRING)/node()/sec:permission)\n"
+ ", if('' eq ($COLL-STRING)) then () else \n"
+ "let $f := fn:function-lookup(xs:QName('xdmp:from-json-string'), 1)\n"
+ "return if (fn:exists($f)) then \n"
+ "xdmp:document-set-collections($URI,json:array-values($f($COLL-STRING)))\n"
+ "else xdmp:document-set-collections($URI,json:array-values(xdmp:from-json($COLL-STRING)))\n"
+ ", if('' eq ($QUALITY-STRING)) then () else xdmp:document-set-quality($URI,xs:integer($QUALITY-STRING))\n"
+ (meta == null ?
"" : ", (let $f := fn:function-lookup(xs:QName('xdmp:document-set-metadata'),2)\n"
+ "return if (exists($f)) then $f($URI,$META) else ())\n");
if (LOG.isDebugEnabled()) {
LOG.debug(query);
}
AdhocQuery req = s.newAdhocQuery(query);
req.setNewStringVariable("URI", uri);
req.setNewStringVariable("XML-STRING", xmlString);
req.setNewStringVariable("PERM-STRING",
permString==null?"":permString);
req.setNewStringVariable("COLL-STRING",
collString==null||collString.isEmpty()?"":collString);
req.setNewStringVariable("QUALITY-STRING",
quality==null?"":quality);
if (meta != null) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode node = mapper.createObjectNode();
for (Map.Entry<String, String> entry : meta.entrySet()) {
node.put(entry.getKey(), entry.getValue());
}
req.setNewVariable("META", ValueType.JS_OBJECT, node);
}
try {
s.submitRequest(req);
return true;
} catch (RequestException ex) {
LOG.error("Error setting document properties for " + uri + ": " +
ex.getMessage());
return false;
}
}
示例10: getXdmValue
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
private XdmValue getXdmValue(String type, String value) {
XQueryItemType itemType = XQueryItemType.valueFor(type);
ValueType xdmType = typeMapper.getType(itemType);
return ValueFactory.newValue(xdmType, value);
}
示例11: getType
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
@Override
public ValueType getType(XQueryItemType itemType) {
ValueType mappedType = typeMap.get(itemType);
validate(itemType, mappedType);
return mappedType;
}
示例12: validate
import com.marklogic.xcc.types.ValueType; //导入依赖的package包/类
private void validate(XQueryItemType itemType, ValueType mappedType) {
if (mappedType == null)
throw new RuntimeException(itemType.getTextRepresentation() + " is not supported");
}