当前位置: 首页>>代码示例>>Java>>正文


Java Binding.getValue方法代码示例

本文整理汇总了Java中org.openrdf.query.Binding.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Binding.getValue方法的具体用法?Java Binding.getValue怎么用?Java Binding.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openrdf.query.Binding的用法示例。


在下文中一共展示了Binding.getValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeDesc

import org.openrdf.query.Binding; //导入方法依赖的package包/类
/**
 * Adds to the description table information for a binding.
 * 
 * @param binding
 */
protected void writeDesc(Binding binding) {
  descData.append(NEWLINE);
  indent(descData, depth + 1);
  descData.append(TABLE_ROW_BEGIN);
  descData.append(TABLE_DATA_BEGIN);
  descData.append(binding.getName());
  descData.append(TABLE_DATA_END);
  descData.append(TABLE_DATA_BEGIN);
  if (binding.getValue() instanceof BNode) {
    descData.append("_:");
  }
  descData.append(binding.getValue().stringValue());
  descData.append(TABLE_DATA_END);
  descData.append(TABLE_ROW_END);
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:21,代码来源:stSPARQLResultsKMLWriter.java

示例2: assertBindingSet

import org.openrdf.query.Binding; //导入方法依赖的package包/类
private static void assertBindingSet(final Iterator<BindingSet> bindingSetIter, final Iterator<Resource> expectedValues) {
    while (expectedValues.hasNext()) {
        final Resource expectedValue = expectedValues.next();
        assertTrue(bindingSetIter.hasNext());
        final BindingSet bindingSet = bindingSetIter.next();
        assertTrue(bindingSet instanceof QueryBindingSet);
        assertEquals(1, bindingSet.getBindingNames().size());
        final Binding binding = bindingSet.getBinding("s");
        assertNotNull(binding);
        final Value actualValue = binding.getValue();
        assertEquals(expectedValue, actualValue);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:OneOfVisitorTest.java

示例3: canJoinBindingSets

import org.openrdf.query.Binding; //导入方法依赖的package包/类
private boolean canJoinBindingSets(BindingSet bs1, BindingSet bs2) {
    for (Binding b : bs1) {
        String name = b.getName();
        Value val = b.getValue();
        if (bs2.hasBinding(name) && (!bs2.getValue(name).equals(val))) {
            return false;
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:11,代码来源:StatementMetadataNode.java

示例4: getBindingValue

import org.openrdf.query.Binding; //导入方法依赖的package包/类
protected String getBindingValue(Binding binding) {
  String val = binding.getValue().stringValue();
  if (binding.getValue() instanceof BNode) {
    val = "_:" + val;
  }

  return val;
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:9,代码来源:stSPARQLResultsKMLWriter.java

示例5: queryOrderAscTest

import org.openrdf.query.Binding; //导入方法依赖的package包/类
@Test
public void queryOrderAscTest() throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	Iterator<String> iter = _orderByAscQueries.iterator();

	while (iter.hasNext()) {
		String query = iter.next();

		TupleQuery cq = CUMULUS_CONNECTION.prepareTupleQuery(QueryLanguage.SPARQL, query);
		TupleQueryResult cRes = cq.evaluate();
		String last = null;
		String current = null;
		while (cRes.hasNext()) {
			BindingSet bs = cRes.next();
			Iterator<Binding> bindings = bs.iterator();
			while (bindings.hasNext()) {
				Binding b = bindings.next();
				Value v = b.getValue();
				if (v instanceof Literal) {
					current = v.stringValue();
					try {
						double currDouble = Double.parseDouble(current);
						double lastDouble;
						if (last == null) {
							lastDouble = -Double.MAX_VALUE;
						} else {
							lastDouble = Double.parseDouble(last);
						}
						assertTrue(currDouble >= lastDouble);
						last = current;
					} catch (NumberFormatException ne) {
						if (last == null) {
							last = "";
						}
						assertTrue(last.compareTo(current) <= 0);
						last = current;
					}
				}
			}
		}
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:42,代码来源:RangeQueryOptimizationTest.java

示例6: queryOrderDescTest

import org.openrdf.query.Binding; //导入方法依赖的package包/类
@Test
public void queryOrderDescTest() throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	Iterator<String> iter = _orderByDescQueries.iterator();

	while (iter.hasNext()) {
		String query = iter.next();

		TupleQuery cq = CUMULUS_CONNECTION.prepareTupleQuery(QueryLanguage.SPARQL, query);
		TupleQueryResult cRes = cq.evaluate();
		String last = null;
		String current = null;
		while (cRes.hasNext()) {
			BindingSet bs = cRes.next();
			Iterator<Binding> bindings = bs.iterator();
			while (bindings.hasNext()) {
				Binding b = bindings.next();
				Value v = b.getValue();
				if (v instanceof Literal) {
					current = v.stringValue();
					try {
						double currDouble = Double.parseDouble(current);
						double lastDouble;
						if (last == null) {
							lastDouble = Double.MAX_VALUE;
						} else {
							lastDouble = Double.parseDouble(last);
						}
						assertTrue(currDouble <= lastDouble);
						last = current;
					} catch (NumberFormatException ne) {
						if (last == null) {
							last = "_";
						}
						assertTrue(last.compareTo(current) >= 0);
						last = current;
					}
				}
			}
		}
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:42,代码来源:RangeQueryOptimizationTest.java

示例7: handleSolution

import org.openrdf.query.Binding; //导入方法依赖的package包/类
@Override
public void handleSolution(BindingSet bindingSet) throws TupleQueryResultHandlerException {
  try {
    StringBuilder value = new StringBuilder();
    Value boundValue = null;
    String href;

    // if set to FALSE, urls link to web. if set to TRUE, urls are described //
    boolean linkURL = true;
    // /////////////////////////////////////////////////////////////////////////


    xmlWriter.startTag(TABLE_ROW_TAG);
    for (String bindingName : bindingNames) {
      Binding binding = bindingSet.getBinding(bindingName);
      if (binding != null) {
        boundValue = binding.getValue();
        value.append(boundValue.stringValue());

        if (boundValue instanceof BNode) {
          value.insert(0, "_:");
        }

        // If the value is a uri, make it link
        if (boundValue instanceof URI) {
          xmlWriter.setAttribute(STYLE, TABLE_DATA_CLASS);
          xmlWriter.startTag(TABLE_DATA_TAG);

          // select all the triples that contain the boundValue
          if (linkURL) {
            String query =
                "select * " + "where " + "{ " + "?subject ?predicate ?object . "
                    + "FILTER((?subject = <" + boundValue.toString() + ">) || "
                    + "(?predicate = <" + boundValue.toString() + ">)  || " + "(?object = <"
                    + boundValue.toString() + ">)) " + "}";

            // FIXME maybe using URLEncoder.encode() for encoding the query and the "boundValue"
            // is not the proper way to encode the final URL (see related bugs #65 and #49), but
            // I am not 100% sure
            href =
                "Browse?view=HTML&query=" + URLEncoder.encode(query, "UTF-8")
                    + "&format=HTML&resource="
                    + URLEncoder.encode(boundValue.toString(), "UTF-8");

          } else {
            href = boundValue.toString();
          }
          xmlWriter.setAttribute(LINK_REF, href);
          xmlWriter.startTag(LINK);
          xmlWriter.text(boundValue.toString());
          xmlWriter.endTag(LINK);
        } else {
          xmlWriter.setAttribute(STYLE, TABLE_DATA_CLASS + " " + MORE_LINK);
          xmlWriter.startTag(TABLE_DATA_TAG);
          xmlWriter.text(boundValue.toString());
        }
        xmlWriter.endTag(TABLE_DATA_TAG);
      } else {
        xmlWriter.setAttribute(STYLE, TABLE_DATA_CLASS);
        xmlWriter.startTag(TABLE_DATA_TAG);
        xmlWriter.endTag(TABLE_DATA_TAG);
      }
      value.setLength(0);
    }
    xmlWriter.endTag(TABLE_ROW_TAG);

  } catch (IOException e) {
    throw new TupleQueryResultHandlerException(e);
  }
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:71,代码来源:stSPARQLResultsHTMLWriter.java


注:本文中的org.openrdf.query.Binding.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。