Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions bundles/org.eclipse.e4.emf.xpath/.settings/.api_filters

This file was deleted.

7 changes: 1 addition & 6 deletions bundles/org.eclipse.e4.emf.xpath/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.e4.emf.xpath
Bundle-Version: 0.5.0.qualifier
Bundle-Version: 0.5.1.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.emf.ecore;bundle-version="2.35.0",
org.eclipse.core.runtime;bundle-version="3.29.0"
Export-Package: org.eclipse.e4.emf.internal.xpath;x-internal:=true,
org.eclipse.e4.emf.internal.xpath.helper;x-friends:="org.eclipse.e4.emf.xpath.test,org.eclipse.e4.ui.model.workbench,org.eclipse.e4.ui.workbench",
org.eclipse.e4.emf.xpath
Import-Package: org.apache.commons.jxpath;version="[1.3.0,2.0.0)",
org.apache.commons.jxpath.ri;version="[1.3.0,2.0.0)",
org.apache.commons.jxpath.ri.compiler;version="[1.3.0,2.0.0)",
org.apache.commons.jxpath.ri.model;version="[1.3.0,2.0.0)",
org.apache.commons.jxpath.util;version="[1.3.0,2.0.0)"
Bundle-Vendor: %Bundle-Vendor
Automatic-Module-Name: org.eclipse.e4.emf.xpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jxpath;

/**
* The {@link JXPathContext#createPath JXPathContext.createPath()} method of
* JXPathContext can create missing objects as it traverses an XPath; it
* utilizes an AbstractFactory for that purpose. Install a factory on
* JXPathContext by calling {@link JXPathContext#setFactory JXPathContext.
* setFactory()}.
* <p>
* All methods of this class return false. Override any of them to return true
* to indicate that the factory has successfully created the described object.
*/
public abstract class AbstractFactory {

/**
* The parameters may describe a collection element or an individual
* object. It is up to the factory to infer which one it is. If it is a
* collection, the factory should check if the collection exists. If not,
* it should create the collection. Then it should create the index'th
* element of the collection and return true.
* <p>
*
* @param context can be used to evaluate other XPaths, get to variables
* etc.
* @param pointer describes the location of the node to be created
* @param parent is the object that will serve as a parent of the new
* object
* @param name is the name of the child of the parent that needs to be
* created. In the case of DOM may be qualified.
* @param index is used if the pointer represents a collection element. You
* may need to expand or even create the collection to accommodate the new
* element.
*
* @return true if the object was successfully created
*/
public boolean createObject(final JXPathContext context, final Pointer pointer,
final Object parent, final String name, final int index) {
return false;
}

/**
* Declare the specified variable
*
* @param context hosts variable pools. See
* {@link JXPathContext#getVariables() JXPathContext.getVariables()}
* @param name is the name of the variable without the "$" sign
* @return true if the variable was successfully defined
*/
public boolean declareVariable(final JXPathContext context, final String name) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jxpath;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* A simple implementation of {@link NodeSet} that behaves as a collection
* of pointers.
*/
public class BasicNodeSet implements NodeSet {
private final List pointers = new ArrayList();
private List readOnlyPointers;
private List nodes;
private List values;

/**
* Add a pointer to this NodeSet.
* @param pointer to add
*/
public void add(final Pointer pointer) {
if (pointers.add(pointer)) {
clearCacheLists();
}
}

/**
* Add the specified NodeSet to this NodeSet.
* @param nodeSet to add
*/
public void add(final NodeSet nodeSet) {
if (pointers.addAll(nodeSet.getPointers())) {
clearCacheLists();
}
}

@Override
public synchronized List getPointers() {
if (readOnlyPointers == null) {
readOnlyPointers = Collections.unmodifiableList(pointers);
}
return readOnlyPointers;
}

@Override
public synchronized List getNodes() {
if (nodes == null) {
nodes = new ArrayList();
for (int i = 0; i < pointers.size(); i++) {
final Pointer pointer = (Pointer) pointers.get(i);
nodes.add(pointer.getNode());
}
nodes = Collections.unmodifiableList(nodes);
}
return nodes;
}

@Override
public synchronized List getValues() {
if (values == null) {
values = new ArrayList();
for (int i = 0; i < pointers.size(); i++) {
final Pointer pointer = (Pointer) pointers.get(i);
values.add(pointer.getValue());
}
values = Collections.unmodifiableList(values);
}
return values;
}

@Override
public String toString() {
return pointers.toString();
}

/**
* Clear cache list members.
*/
private synchronized void clearCacheLists() {
readOnlyPointers = null;
nodes = null;
values = null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.jxpath;

import java.util.HashMap;

/**
* A basic implementation of the Variables interface that uses a HashMap.
*/
public class BasicVariables implements Variables {
private static final long serialVersionUID = 2708263960832062725L;

/**
* Contains the values of declared variables
*/
private final HashMap vars = new HashMap();

/**
* Returns true if the variable has been defined, even if the
* value of the variable is null.
*
* @param varName is a variable name without the "$" sign
* @return true if the variable is declared
*/
@Override
public boolean isDeclaredVariable(final String varName) {
return vars.containsKey(varName);
}

/**
* Returns the value of the variable if it is defined,
* otherwise, throws IllegalArgumentException
*
* @param varName is a variable name without the "$" sign
* @return the value of the variable
*/
@Override
public Object getVariable(final String varName) {
// Note that a variable may be defined with a null value

if (vars.containsKey(varName)) {
return vars.get(varName);
}

throw new IllegalArgumentException(
"No such variable: '" + varName + "'");
}

/**
* Defines a new variable with the specified value or modifies
* the value of an existing variable.
*
* @param varName is a variable name without the "$" sign
* @param value is the new value for the variable, which can be null
*/
@Override
public void declareVariable(final String varName, final Object value) {
vars.put(varName, value);
}

/**
* Removes an existing variable. May throw UnsupportedOperationException.
*
* @param varName is a variable name without the "$" sign
*/
@Override
public void undeclareVariable(final String varName) {
vars.remove(varName);
}

@Override
public String toString() {
return vars.toString();
}
}
Loading
Loading