本文整理汇总了Java中org.jruby.RubyArray.append方法的典型用法代码示例。如果您正苦于以下问题:Java RubyArray.append方法的具体用法?Java RubyArray.append怎么用?Java RubyArray.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jruby.RubyArray
的用法示例。
在下文中一共展示了RubyArray.append方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyLoadPaths
import org.jruby.RubyArray; //导入方法依赖的package包/类
/**
* applyLoadPaths
*
* @param container
*/
protected void applyLoadPaths(Ruby runtime)
{
if (this._loadPaths != null && this._loadPaths.size() > 0)
{
IRubyObject object = runtime.getLoadService().getLoadPath();
if (object instanceof RubyArray)
{
RubyArray loadPathArray = (RubyArray) object;
// save copy for later
this._originalLoadPaths = (RubyArray) loadPathArray.dup();
// Add our custom load paths
for (String loadPath : this._loadPaths)
{
RubyString toAdd = runtime.newString(loadPath.replace('\\', '/'));
loadPathArray.append(toAdd);
}
}
}
}
示例2: add
import org.jruby.RubyArray; //导入方法依赖的package包/类
@JRubyMethod(name = {"add", "append"}, required = 1)
public IRubyObject add(ThreadContext context, IRubyObject val) {
if (cnt - tailoff() < 32) {
PersistentVector ret = new PersistentVector(context.runtime, getMetaClass());
RubyArray newTail = tail.aryDup();
newTail.append(val);
return ret.initialize(context, this.cnt+1, this.shift, this.root, newTail);
}
Node newroot;
Node tailnode = new Node(context.runtime, Node).initialize_params_arry(context, root.edit, tail);
int newshift = shift;
if ((cnt >>> 5) > (1 << shift)) {
newroot = new Node(context.runtime, Node).initialize_params(context, root.edit);
newroot.array.store(0, root);
newroot.array.store(1, newPath(context, root.edit, shift, tailnode));
newshift += 5;
} else
newroot = pushTail(context, shift, root, tailnode);
RubyArray arry = RubyArray.newArray(context.runtime);
arry.store(0, val);
return new PersistentVector(context.runtime, getMetaClass()).initialize(context, cnt + 1, newshift, newroot, arry);
}
示例3: read
import org.jruby.RubyArray; //导入方法依赖的package包/类
@JRubyMethod
public IRubyObject read(ThreadContext context) {
position++;
while (nodeQueue.size() <= position && continueParsing) {
readMoreData(context);
}
if(currentNode() == null) {
return context.nil;
} else if(currentNode().isError()) {
RubyArray errors = (RubyArray) this.getInstanceVariable("@errors");
errors.append(currentNode().toSyntaxError());
this.setInstanceVariable("@errors", errors);
throw new RaiseException((XmlSyntaxError) currentNode().toSyntaxError());
} else {
return this;
}
}
示例4: getAttributesNodes
import org.jruby.RubyArray; //导入方法依赖的package包/类
public IRubyObject getAttributesNodes() {
RubyArray array = RubyArray.newArray(ruby);
if (attributeList != null && attributeList.length > 0) {
if (document == null) {
XmlDocument doc = (XmlDocument) XmlDocument.rbNew(ruby.getCurrentContext(), getNokogiriClass(ruby, "Nokogiri::XML::Document"), new IRubyObject[0]);
document = doc.getDocument();
}
for (int i=0; i<attributeList.length; i++) {
if (!isNamespace(attributeList.names.get(i))) {
Attr attr = document.createAttributeNS(attributeList.namespaces.get(i), attributeList.names.get(i));
attr.setValue(attributeList.values.get(i));
XmlAttr xmlAttr = (XmlAttr) NokogiriService.XML_ATTR_ALLOCATOR.allocate(ruby, getNokogiriClass(ruby, "Nokogiri::XML::Attr"));
xmlAttr.setNode(ruby.getCurrentContext(), attr);
array.append(xmlAttr);
}
}
}
return array;
}
示例5: attribute_nodes
import org.jruby.RubyArray; //导入方法依赖的package包/类
@JRubyMethod
public IRubyObject attribute_nodes(ThreadContext context) {
NamedNodeMap nodeMap = this.node.getAttributes();
Ruby ruby = context.getRuntime();
if(nodeMap == null){
return ruby.newEmptyArray();
}
RubyArray attr = ruby.newArray();
for(int i = 0; i < nodeMap.getLength(); i++) {
if ((doc instanceof HtmlDocument) || !NokogiriHelpers.isNamespace(nodeMap.item(i))) {
attr.append(getCachedNodeOrCreate(context.getRuntime(), nodeMap.item(i)));
}
}
return attr;
}
示例6: enumeration
import org.jruby.RubyArray; //导入方法依赖的package包/类
/**
* FIXME: will enumerations all be of the simple (val1|val2|val3)
* type string?
*/
@JRubyMethod
public IRubyObject enumeration(ThreadContext context) {
RubyArray enumVals = RubyArray.newArray(context.getRuntime());
String atype = ((Element)node).getAttribute("atype");
if (atype != null && atype.length() != 0 && atype.charAt(0) == '(') {
// removed enclosing parens
String valueStr = atype.substring(1, atype.length() - 1);
String[] values = valueStr.split("\\|");
for (int i = 0; i < values.length; i++) {
enumVals.append(context.getRuntime().newString(values[i]));
}
}
return enumVals;
}
示例7: collectCurrent
import org.jruby.RubyArray; //导入方法依赖的package包/类
private RubyArray collectCurrent() {
RubyArray bindings = RubyArray.newArray(runtime);
while (iterator.hasNext()) {
bindings.append(((IRubyObject) RubyBinding.newBinding(runtime, iterator.next())));
}
return bindings;
}
示例8: nodeArrayToRubyArray
import org.jruby.RubyArray; //导入方法依赖的package包/类
public static RubyArray nodeArrayToRubyArray(Ruby ruby, Node[] nodes) {
RubyArray n = RubyArray.newArray(ruby, nodes.length);
for(int i = 0; i < nodes.length; i++) {
n.append(NokogiriHelpers.getCachedNodeOrCreate(ruby, nodes[i]));
}
return n;
}
示例9: namedNodeMapToRubyArray
import org.jruby.RubyArray; //导入方法依赖的package包/类
public static RubyArray namedNodeMapToRubyArray(Ruby ruby, NamedNodeMap map) {
RubyArray n = RubyArray.newArray(ruby, map.getLength());
for(int i = 0; i < map.getLength(); i++) {
n.append(NokogiriHelpers.getCachedNodeOrCreate(ruby, map.item(i)));
}
return n;
}
示例10: namespace_scopes
import org.jruby.RubyArray; //导入方法依赖的package包/类
/**
* Return an array of XmlNamespace nodes defined on this node and
* on any ancestor node.
*/
@JRubyMethod
public IRubyObject namespace_scopes(ThreadContext context) {
RubyArray scoped_namespaces = context.getRuntime().newArray();
if (doc == null) return scoped_namespaces;
if (doc instanceof HtmlDocument) return scoped_namespaces;
Node previousNode;
if (node.getNodeType() == Node.ELEMENT_NODE) {
previousNode = node;
} else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
previousNode = ((Attr)node).getOwnerElement();
} else {
previousNode = findPreviousElement(node);
}
if (previousNode == null) return scoped_namespaces;
List<String> prefixes_in_scope = new ArrayList<String>();
NokogiriNamespaceCache nsCache = NokogiriHelpers.getNamespaceCacheFormNode(previousNode);
for (Node previous=previousNode; previous != null; ) {
List<XmlNamespace> namespaces = nsCache.get(previous);
for (XmlNamespace namespace : namespaces) {
if (prefixes_in_scope.contains(namespace.getPrefix())) continue;
scoped_namespaces.append(namespace);
prefixes_in_scope.add(namespace.getPrefix());
}
previous = findPreviousElement(previous);
}
return scoped_namespaces;
}
示例11: nodeListToRubyArray
import org.jruby.RubyArray; //导入方法依赖的package包/类
public static RubyArray nodeListToRubyArray(Ruby ruby, NodeList nodes, RubyArray array) {
for(int i = 0; i < nodes.getLength(); i++) {
array.append(NokogiriHelpers.getCachedNodeOrCreate(ruby, nodes.item(i)));
}
return array;
}