本文整理匯總了Java中org.core4j.Enumerable類的典型用法代碼示例。如果您正苦於以下問題:Java Enumerable類的具體用法?Java Enumerable怎麽用?Java Enumerable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Enumerable類屬於org.core4j包,在下文中一共展示了Enumerable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseOrderBy
import org.core4j.Enumerable; //導入依賴的package包/類
/**
* orderbyのパース.
* @param value orderbyの値
* @return パース結果
*/
public static List<OrderByExpression> parseOrderBy(String value) {
List<Token> tokens = tokenize(value);
// dump(value,tokens,null);
List<CommonExpression> expressions = readExpressions(tokens);
if (ExpressionParser.DUMP_EXPRESSION_INFO) {
dump(value, tokens, Enumerable.create(expressions).toArray(CommonExpression.class));
}
return Enumerable.create(expressions).select(new Func1<CommonExpression, OrderByExpression>() {
public OrderByExpression apply(CommonExpression input) {
if (input instanceof OrderByExpression) {
return (OrderByExpression) input;
}
return Expression.orderBy(input, Direction.ASCENDING); // default to asc
}
}).toList();
}
示例2: parseExpand
import org.core4j.Enumerable; //導入依賴的package包/類
/**
* selectのパース.
* @param value selectの値
* @return パース結果
*/
public static List<EntitySimpleProperty> parseExpand(String value) {
List<Token> tokens = tokenize(value);
// dump(value,tokens,null);
List<CommonExpression> expressions = readExpressions(tokens);
// since we support currently simple properties only we have to
// confine ourselves to EntitySimpleProperties.
return Enumerable.create(expressions).select(new Func1<CommonExpression, EntitySimpleProperty>() {
public EntitySimpleProperty apply(CommonExpression input) {
if (input instanceof EntitySimpleProperty) {
return (EntitySimpleProperty) input;
}
return null;
}
}).toList();
}
示例3: parseExpandQuery
import org.core4j.Enumerable; //導入依賴的package包/類
/**
* expandのパース.
* @param value expandの値
* @return パース結果
*/
public static List<EntitySimpleProperty> parseExpandQuery(String value) {
List<Token> tokens = tokenize(value);
for (Token token : tokens) {
if (!token.value.equals(",") && !token.value.startsWith("_")) {
throw new RuntimeException("Invalid navigationProperty name.(" + token.toString() + ")");
}
}
List<CommonExpression> expressions = readExpressions(tokens);
// since we support currently simple properties only we have to
// confine ourselves to EntitySimpleProperties.
return Enumerable.create(expressions).select(new Func1<CommonExpression, EntitySimpleProperty>() {
public EntitySimpleProperty apply(CommonExpression input) {
if (input instanceof EntitySimpleProperty) {
return (EntitySimpleProperty) input;
}
return null;
}
}).toList();
}
示例4: getOrCreateEntityType
import org.core4j.Enumerable; //導入依賴的package包/類
RdfEntityType getOrCreateEntityType(RdfNode entityTypeNode, RdfNode entityTypeLabelNode)
throws OData2SparqlException {
RdfURI classURI = new RdfURI(entityTypeNode);
RdfEntityType clazz = Enumerable.create(classURI.graph.classes)
.firstOrNull(classNameEquals(classURI.localName));
if (clazz == null) {
clazz = new RdfEntityType();
clazz.schema = classURI.graph;
clazz.entityTypeName = rdfToOdata(classURI.localName);
if (entityTypeLabelNode == null) {
clazz.entityTypeLabel = RdfConstants.CLASS_LABEL_PREFIX + clazz.entityTypeName;
} else {
clazz.entityTypeLabel = entityTypeLabelNode.getLiteralObject().toString();
}
clazz.entityTypeNode = entityTypeNode;
classURI.graph.classes.add(clazz);
}
return clazz;
}
示例5: getOrCreateProperty
import org.core4j.Enumerable; //導入依賴的package包/類
RdfProperty getOrCreateProperty(RdfNode propertyNode, RdfNode propertyLabelNode, RdfNode domainNode)
throws OData2SparqlException {
RdfURI propertyURI = new RdfURI(propertyNode);
RdfEntityType clazz = this.getOrCreateEntityType(domainNode);
RdfProperty property = Enumerable.create(clazz.getProperties()).firstOrNull(
propertyNameEquals(propertyURI.localName));
if (property == null) {
property = new RdfProperty();
property.propertyName = rdfToOdata(propertyURI.localName);
if (propertyLabelNode == null) {
property.propertyLabel = RdfConstants.PROPERTY_LABEL_PREFIX + property.propertyName;
} else {
property.propertyLabel = propertyLabelNode.getLiteralObject().toString();
}
property.propertyNode = propertyNode;
property.ofClass = clazz;
clazz.properties.put(property.propertyName, property);
}
return property;
}
示例6: testCallFunctionFromConsumer
import org.core4j.Enumerable; //導入依賴的package包/類
@Test
public void testCallFunctionFromConsumer() throws Exception {
for (FormatType format : FunctionsActionsTest.formats) {
ODataConsumer c = rtFacade.createODataConsumer(endpointUri, format, null);
OEntityGetRequest<OEntity> getEntityRrequest = c.getEntity("Employees", "abc123");
ODataConsumer.dump.all(true);
OEntity employee = getEntityRrequest.execute();
Enumerable<OObject> result = c.callFunction(FunctionsActionsMetadataUtil.TEST_BOUND_FUNCTION)
.parameter("employee", employee)
.pString("p2", "value")
.execute();
ODataConsumer.dump.all(true);
assertNotNull(result);
OObject resultEntity = result.first();
assertTrue(resultEntity instanceof OSimpleObject<?>);
assertEquals("abc123-value", ((OSimpleObject<?>) resultEntity).getValue());
}
}
示例7: startElement
import org.core4j.Enumerable; //導入依賴的package包/類
public void startElement(QName2 qname, String xmlns) {
// writer.setDefaultNamespace("http://www.example.com/ns1");
try {
Iterator<?> nsIterator = null;
if (xmlns != null) {
nsIterator = Enumerable.create(eventFactory.createNamespace(xmlns)).iterator();
}
// writer.writeStartElement(prefix,localName,namespaceURI);
XMLEvent event = eventFactory.createStartElement(StaxXMLFactoryProvider2.toQName(qname), null, nsIterator);
eventWriter.add(event);
} catch (XMLStreamException e) {
throw Throwables.propagate(e);
}
}
示例8: execute
import org.core4j.Enumerable; //導入依賴的package包/類
@Override
public void execute() throws ODataProducerException {
ODataClientRequest request = null;
if (updateRoot != null) {
OEntity entity = (OEntity) updateRoot;
// if mediaStream is set, then first send put request for updating only media link;
if (Boolean.TRUE.equals(entitySet.getType().getHasStream()) && isMediaStreamSet(entity)) {
String path = Enumerable.create(segments).join("/");
request = new ODataClientRequest("PUT", serviceRootUri + path, null, null, entity.getMediaLinkStream());
client.updateEntity(request);
}
}
// send regular merge/put request for updating non-stream properties
request = getRequest();
client.updateEntity(request);
}
示例9: testCallBoundFunctionFromConsumer
import org.core4j.Enumerable; //導入依賴的package包/類
@Test
public void testCallBoundFunctionFromConsumer() throws Exception {
for (FormatType format : FunctionsActionsTest.formats) {
ODataConsumer c = rtFacade.createODataConsumer(endpointUri, format, null);
OEntity employee = c.getEntity("Employees", "abc123").execute();
Enumerable<OObject> result = c.callFunction(FunctionsActionsMetadataUtil.CONTAINER_NAME + "." + FunctionsActionsMetadataUtil.TEST_OVERLOADED_BOUND_FUNCTION)
.bind("Employees", employee.getEntityKey())
.pString("p2", "value")
.execute();
assertNotNull(result);
OObject resultEntity = result.first();
assertTrue(resultEntity instanceof OSimpleObject<?>);
String expected = FunctionsActionsMetadataUtil.TEST_OVERLOADED_BOUND_FUNCTION + "-" + "Employees('abc123')" + "-" + "value";
assertEquals(expected, ((OSimpleObject<?>) resultEntity).getValue());
}
}
示例10: parseFeed
import org.core4j.Enumerable; //導入依賴的package包/類
AtomFeed parseFeed(XMLEventReader2 reader, EdmEntitySet entitySet) {
AtomFeed feed = new AtomFeed();
List<AtomEntry> rt = new ArrayList<AtomEntry>();
while (reader.hasNext()) {
XMLEvent2 event = reader.nextEvent();
if (isStartElement(event, ATOM_ENTRY)) {
rt.add(parseEntry(reader, event.asStartElement(), entitySet));
} else if (isStartElement(event, ATOM_LINK)) {
if ("next".equals(event.asStartElement().getAttributeByName(new QName2("rel")).getValue())) {
feed.next = event.asStartElement().getAttributeByName(new QName2("href")).getValue();
}
} else if (isEndElement(event, ATOM_FEED)) {
// return from a sub feed, if we went down the hierarchy
break;
}
}
feed.entries = Enumerable.create(rt).cast(Entry.class);
return feed;
}
示例11: getAnnotations
import org.core4j.Enumerable; //導入依賴的package包/類
protected List<EdmAnnotation<?>> getAnnotations(StartElement2 element) {
// extract Annotation attributes
try {
Enumerable<Attribute2> atts = element.getAttributes();
List<EdmAnnotation<?>> annots = new ArrayList<EdmAnnotation<?>>();
for (Attribute2 att : atts) {
QName2 q = att.getName();
if (isExtensionNamespace(q.getNamespaceUri())) {
// a user extension
annots.add(EdmAnnotation.attribute(q.getNamespaceUri(), q.getPrefix(), q.getLocalPart(), att.getValue()));
}
}
return annots;
} catch (Exception ex) {
// not all of the xml parsing implementations implement getAttributes() yet.
return null;
}
}
示例12: getExtensionNamespaces
import org.core4j.Enumerable; //導入依賴的package包/類
protected List<PrefixedNamespace> getExtensionNamespaces(StartElement2 startElement) {
try {
Enumerable<Namespace2> nse = startElement.getNamespaces();
List<PrefixedNamespace> nsl = new ArrayList<PrefixedNamespace>();
for (Namespace2 ns : nse) {
if (this.isExtensionNamespace(ns.getNamespaceURI())) {
nsl.add(new PrefixedNamespace(ns.getNamespaceURI(), ns.getPrefix()));
}
}
return nsl;
} catch (Exception ex) {
// not all of the xml parsing implementations implement getNamespaces() yet.
return null;
}
}
示例13: getCollectionValue
import org.core4j.Enumerable; //導入依賴的package包/類
/**
* Returns a collection from a property in an instance.
*
* @param target the instance to look at
* @param collectionName the name of the property on the instance which holds the collection
* @return an iterable containing the elements of the collection
*/
public Iterable<?> getCollectionValue(Object target, String collectionName) {
Method method = getGetter(collectionName);
if (!method.isAccessible())
method.setAccessible(true);
try {
Object obj = method.invoke(target);
if (obj == null)
return null;
else
return obj.getClass().isArray()
? Enumerable.create((Object[]) obj)
: (Iterable<?>) obj;
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
示例14: reflectionToString
import org.core4j.Enumerable; //導入依賴的package包/類
public static String reflectionToString(final Object obj) {
StringBuilder rt = new StringBuilder();
Class<?> objClass = obj.getClass();
rt.append(objClass.getSimpleName());
rt.append('[');
String content = Enumerable.create(objClass.getFields())
.select(Funcs.wrap(new ThrowingFunc1<Field, String>() {
public String apply(Field f) throws Exception {
Object fValue = f.get(obj);
return f.getName() + ":" + fValue;
}
})).join(",");
rt.append(content);
rt.append(']');
return rt.toString();
}
示例15: main
import org.core4j.Enumerable; //導入依賴的package包/類
public static void main(String[] args) {
final TreeNode root = new TreeNode("root",
new TreeNode("a",
new TreeNode("a.a"),
new TreeNode("a.b")),
new TreeNode("b",
new TreeNode("b.a",
new TreeNode("b.a.a"))),
new TreeNode("c"));
Enumerable<TreeNode> treeEnum = Enumerable.createFromIterator(new Func<Iterator<TreeNode>>() {
public Iterator<TreeNode> apply() {
return new DepthFirstIterator<TreeNode>(root, GET_CHILDREN);
}
});
for (TreeNode node : treeEnum) {
System.out.println(node.value);
}
}