Permalink
Browse files

Use generics properly

  • Loading branch information...
sharwell committed Sep 23, 2013
1 parent e87abe9 commit 967351f92c01b3d1bd49235f0868d096745e17cc
Showing with 135 additions and 133 deletions.
  1. +2 −2 src/com/xmlcalabash/core/XProcConfiguration.java
  2. +5 −5 src/com/xmlcalabash/core/XProcRuntime.java
  3. +12 −10 src/com/xmlcalabash/drivers/CalabashTask.java
  4. +4 −4 src/com/xmlcalabash/extensions/MetadataExtractor.java
  5. +4 −4 src/com/xmlcalabash/extensions/Zip.java
  6. +2 −2 src/com/xmlcalabash/functions/BaseURI.java
  7. +1 −1 src/com/xmlcalabash/functions/Cwd.java
  8. +1 −1 src/com/xmlcalabash/functions/IterationPosition.java
  9. +1 −1 src/com/xmlcalabash/functions/IterationSize.java
  10. +3 −3 src/com/xmlcalabash/functions/ResolveURI.java
  11. +2 −2 src/com/xmlcalabash/functions/StepAvailable.java
  12. +2 −2 src/com/xmlcalabash/functions/SystemProperty.java
  13. +4 −4 src/com/xmlcalabash/functions/ValueAvailable.java
  14. +2 −2 src/com/xmlcalabash/functions/VersionAvailable.java
  15. +2 −2 src/com/xmlcalabash/functions/XPathVersionAvailable.java
  16. +2 −2 src/com/xmlcalabash/io/Select.java
  17. +2 −2 src/com/xmlcalabash/library/SplitSequence.java
  18. +2 −2 src/com/xmlcalabash/library/Template.java
  19. +1 −1 src/com/xmlcalabash/library/ValidateWithXSD.java
  20. +2 −2 src/com/xmlcalabash/library/WrapSequence.java
  21. +2 −2 src/com/xmlcalabash/model/Parser.java
  22. +2 −2 src/com/xmlcalabash/runtime/XAtomicStep.java
  23. +2 −2 src/com/xmlcalabash/runtime/XSelect.java
  24. +6 −5 src/com/xmlcalabash/util/CollectionResolver.java
  25. +7 −6 src/com/xmlcalabash/util/DocumentSequenceIterator.java
  26. +8 −8 src/com/xmlcalabash/util/JSONtoXML.java
  27. +2 −2 src/com/xmlcalabash/util/S9apiUtils.java
  28. +2 −2 src/com/xmlcalabash/util/XPointerScheme.java
  29. +2 −2 src/com/xmlcalabash/util/XProcNamespaceContext.java
  30. +2 −2 src/org/json/CookieList.java
  31. +2 −2 src/org/json/HTTP.java
  32. +6 −6 src/org/json/JSONArray.java
  33. +4 −4 src/org/json/JSONML.java
  34. +26 −28 src/org/json/JSONObject.java
  35. +4 −4 src/org/json/Test.java
  36. +2 −2 src/org/json/XML.java
@@ -474,8 +474,8 @@ public XProcStep newStep(XProcRuntime runtime,XAtomicStep step){
}
try {
Constructor constructor = Class.forName(className).getConstructor(XProcRuntime.class, XAtomicStep.class);
return (XProcStep) constructor.newInstance(runtime,step);
Constructor<? extends XProcStep> constructor = Class.forName(className).asSubclass(XProcStep.class).getConstructor(XProcRuntime.class, XAtomicStep.class);
return constructor.newInstance(runtime,step);
} catch (NoSuchMethodException nsme) {
throw new UnsupportedOperationException("No such method: " + className, nsme);
} catch (ClassNotFoundException cfne) {
@@ -177,8 +177,8 @@ public XProcRuntime(XProcConfiguration config) {
if (config.xprocConfigurer != null) {
try {
String className = config.xprocConfigurer;
Constructor constructor = Class.forName(className).getConstructor(XProcRuntime.class);
configurer = (XProcConfigurer) constructor.newInstance(this);
Constructor<? extends XProcConfigurer> constructor = Class.forName(className).asSubclass(XProcConfigurer.class).getConstructor(XProcRuntime.class);
configurer = constructor.newInstance(this);
} catch (Exception e) {
throw new XProcException(e);
}
@@ -212,14 +212,14 @@ public XProcRuntime(XProcConfiguration config) {
try {
if (config.uriResolver != null) {
uriResolver.setUnderlyingURIResolver((URIResolver) Class.forName(config.uriResolver).newInstance());
uriResolver.setUnderlyingURIResolver(Class.forName(config.uriResolver).asSubclass(URIResolver.class).newInstance());
}
if (config.entityResolver != null) {
uriResolver.setUnderlyingEntityResolver((EntityResolver) Class.forName(config.entityResolver).newInstance());
uriResolver.setUnderlyingEntityResolver(Class.forName(config.entityResolver).asSubclass(EntityResolver.class).newInstance());
}
if (config.errorListener != null) {
msgListener = (XProcMessageListener) Class.forName(config.errorListener).newInstance();
msgListener = Class.forName(config.errorListener).asSubclass(XProcMessageListener.class).newInstance();
} else {
msgListener = new DefaultXProcMessageListener();
}
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.xml.transform.URIResolver;
import com.xmlcalabash.util.Input.Type;
import com.xmlcalabash.util.UserArgs;
@@ -47,6 +48,7 @@
import org.apache.tools.ant.types.resources.Resources;
import org.apache.tools.ant.types.resources.Union;
import org.apache.tools.ant.util.FileNameMapper;
import org.xml.sax.EntityResolver;
import static com.xmlcalabash.util.Input.Type.DATA;
import static com.xmlcalabash.util.Input.Type.XML;
@@ -340,7 +342,7 @@ public void addConfiguredPipeline(UseableResources pipeline) {
handleError("The pipeline element must be specified with at most one nested resource.");
}
setPipeline((Resource) pipeline.iterator().next());
setPipeline(pipeline.iterator().next());
}
/**
@@ -732,7 +734,7 @@ public void addConfiguredProfile(UseableResources profile) {
handleError("The profile element must be specified with at most one nested resource.");
}
setProfileFile((Resource) profile.iterator().next());
setProfileFile(profile.iterator().next());
}
/**
@@ -780,7 +782,7 @@ public void addConfiguredSaxonConfig(UseableResources saxonConfig) {
handleError("The saxonConfig element must be specified with at most one nested resource.");
}
setSaxonConfigFile((Resource) saxonConfig.iterator().next());
setSaxonConfigFile(saxonConfig.iterator().next());
}
/**
@@ -841,7 +843,7 @@ public void addConfiguredConfig(UseableResources config) {
handleError("The config element must be specified with at most one nested resource.");
}
setConfigFile((Resource) config.iterator().next());
setConfigFile(config.iterator().next());
}
/**
@@ -862,7 +864,7 @@ public void setLogStyle(String logStyle) {
*
* @param entityResolver the resolver class for entity resolution
*/
public void setEntityResolver(Class entityResolver) {
public void setEntityResolver(Class<? extends EntityResolver> entityResolver) {
try {
userArgs.setEntityResolverClass(entityResolver.getName());
} catch (Exception e) {
@@ -875,7 +877,7 @@ public void setEntityResolver(Class entityResolver) {
*
* @param uriResolver the resolver class for URI resolution
*/
public void setURIResolver(Class uriResolver) {
public void setURIResolver(Class<? extends URIResolver> uriResolver) {
try {
userArgs.setUriResolverClass(uriResolver.getName());
} catch (Exception e) {
@@ -895,8 +897,8 @@ public void addConfiguredLibrary(UseableResources libraries) {
}
try {
for (Iterator iterator = libraries.iterator(); iterator.hasNext(); ) {
Resource library = (Resource) iterator.next();
for (Iterator<Resource> iterator = libraries.iterator(); iterator.hasNext(); ) {
Resource library = iterator.next();
userArgs.addLibrary(library.getInputStream(), library.toString());
}
} catch (Exception e) {
@@ -1262,8 +1264,8 @@ private void process(Map<String, List<TypedResource>> inputResources, Map<String
try {
for (String port : outputResources.keySet()) {
Union resources = outputResources.get(port);
for (Iterator iterator = resources.iterator(); iterator.hasNext(); ) {
Resource resource = (Resource) iterator.next();
for (Iterator<Resource> iterator = resources.iterator(); iterator.hasNext(); ) {
Resource resource = iterator.next();
userArgs.addOutput(port, resource.getOutputStream());
}
}
@@ -89,13 +89,13 @@ public void run() throws SaxonApiException {
tree.startContent();
// iterate through metadata directories
Iterator directories = metadata.getDirectories().iterator();
Iterator<Directory> directories = metadata.getDirectories().iterator();
while (directories.hasNext()) {
Directory directory = (Directory) directories.next();
Directory directory = directories.next();
String dir = directory.getName();
Iterator tags = directory.getTags().iterator();
Iterator<Tag> tags = directory.getTags().iterator();
while (tags.hasNext()) {
Tag tag = (Tag) tags.next();
Tag tag = tags.next();
tree.addStartElement(c_tag);
tree.addAttribute(_dir, dir);
@@ -297,9 +297,9 @@ public void update(ZipFile inZip, ZipOutputStream outZip, boolean freshen) {
try {
if (inZip != null) {
Enumeration zenum = inZip.entries();
Enumeration<? extends ZipEntry> zenum = inZip.entries();
while (zenum.hasMoreElements()) {
ZipEntry entry = (ZipEntry) zenum.nextElement();
ZipEntry entry = zenum.nextElement();
String name = entry.getName();
boolean skip = srcManifest.containsKey(name);
@@ -405,9 +405,9 @@ public void update(ZipFile inZip, ZipOutputStream outZip, boolean freshen) {
public void delete(ZipFile inZip, ZipOutputStream outZip) {
try {
if (inZip != null) {
Enumeration zenum = inZip.entries();
Enumeration<? extends ZipEntry> zenum = inZip.entries();
while (zenum.hasMoreElements()) {
ZipEntry entry = (ZipEntry) zenum.nextElement();
ZipEntry entry = zenum.nextElement();
String name = entry.getName();
boolean delete = false;
@@ -78,7 +78,7 @@ public ExtensionFunctionCall makeCallExpression() {
}
private class BaseURICall extends ExtensionFunctionCall {
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
String baseURI = null;
XProcRuntime runtime = tl_runtime.get();
@@ -90,7 +90,7 @@ public SequenceIterator call(SequenceIterator[] arguments, XPathContext context)
}
if (arguments.length > 0) {
SequenceIterator iter = arguments[0];
SequenceIterator<?> iter = arguments[0];
NodeInfo item = (NodeInfo) iter.next();
baseURI = item.getBaseURI();
} else {
@@ -74,7 +74,7 @@ public ExtensionFunctionCall makeCallExpression() {
}
private class CwdCall extends ExtensionFunctionCall {
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
XProcRuntime runtime = tl_runtime.get();
XStep step = runtime.getXProcData().getStep();
@@ -74,7 +74,7 @@ public ExtensionFunctionCall makeCallExpression() {
}
private class IterationPositionCall extends ExtensionFunctionCall {
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
XProcRuntime runtime = tl_runtime.get();
XProcData data = runtime.getXProcData();
XStep step = data.getStep();
@@ -73,7 +73,7 @@ public ExtensionFunctionCall makeCallExpression() {
}
private class IterationPositionCall extends ExtensionFunctionCall {
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
XProcRuntime runtime = tl_runtime.get();
XStep step = runtime.getXProcData().getStep();
// FIXME: this can't be the best way to do this...
@@ -82,8 +82,8 @@ public ExtensionFunctionCall makeCallExpression() {
}
private class ResolveURICall extends ExtensionFunctionCall {
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
SequenceIterator iter = arguments[0];
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
SequenceIterator<?> iter = arguments[0];
String relativeURI = iter.next().getStringValue();
XProcRuntime runtime = tl_runtime.get();
@@ -102,7 +102,7 @@ public SequenceIterator call(SequenceIterator[] arguments, XPathContext context)
baseURI = runtime.getStaticBaseURI().toASCIIString();
try {
// FIXME: TinyDocumentImpl? Surely we can do better than that!
Item item = context.getContextItem();
Item<?> item = context.getContextItem();
baseURI = ((TinyDocumentImpl) item).getBaseURI();
} catch (Exception e) {
// nop
@@ -84,7 +84,7 @@ public void supplyStaticContext(StaticContext context, int locationId, Expressio
staticContext = context;
}
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
StructuredQName stepName = null;
XProcRuntime runtime = tl_runtime.get();
@@ -96,7 +96,7 @@ public SequenceIterator call(SequenceIterator[] arguments, XPathContext context)
}
try {
SequenceIterator iter = arguments[0];
SequenceIterator<?> iter = arguments[0];
String lexicalQName = iter.next().getStringValue();
stepName = StructuredQName.fromLexicalQName(
lexicalQName,
@@ -63,7 +63,7 @@ public void supplyStaticContext(StaticContext context, int locationId, Expressio
staticContext = context;
}
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
StructuredQName propertyName = null;
XProcRuntime runtime = tl_runtime.get();
@@ -75,7 +75,7 @@ public SequenceIterator call(SequenceIterator[] arguments, XPathContext context)
}
try {
SequenceIterator iter = arguments[0];
SequenceIterator<?> iter = arguments[0];
String lexicalQName = iter.next().getStringValue();
propertyName = StructuredQName.fromLexicalQName(
lexicalQName,
@@ -85,7 +85,7 @@ public void supplyStaticContext(StaticContext context, int locationId, Expressio
staticContext = context;
}
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
StructuredQName sVarName = null;
XProcRuntime runtime = tl_runtime.get();
@@ -97,7 +97,7 @@ public SequenceIterator call(SequenceIterator[] arguments, XPathContext context)
}
try {
SequenceIterator iter = arguments[0];
SequenceIterator<?> iter = arguments[0];
String lexicalQName = iter.next().getStringValue();
sVarName = StructuredQName.fromLexicalQName(
lexicalQName,
@@ -112,9 +112,9 @@ public SequenceIterator call(SequenceIterator[] arguments, XPathContext context)
boolean failIfUnknown = true;
if (arguments.length > 1) {
SequenceIterator iter = arguments[1];
SequenceIterator<?> iter = arguments[1];
iter = iter.next().getTypedValue();
Item item = iter.next();
Item<?> item = iter.next();
failIfUnknown = ((BooleanValue) item).effectiveBooleanValue();
}
@@ -74,8 +74,8 @@ public ExtensionFunctionCall makeCallExpression() {
}
private class SystemPropertyCall extends ExtensionFunctionCall {
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
SequenceIterator iter = arguments[0];
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
SequenceIterator<?> iter = arguments[0];
XProcRuntime runtime = tl_runtime.get();
XStep step = runtime.getXProcData().getStep();
@@ -74,8 +74,8 @@ public ExtensionFunctionCall makeCallExpression() {
}
private class SystemPropertyCall extends ExtensionFunctionCall {
public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
SequenceIterator iter = arguments[0];
public SequenceIterator<?> call(SequenceIterator<?>[] arguments, XPathContext context) throws XPathException {
SequenceIterator<?> iter = arguments[0];
XProcRuntime runtime = tl_runtime.get();
XStep step = runtime.getXProcData().getStep();
@@ -95,9 +95,9 @@ private void readSource() {
selector.setContextItem(doc);
Iterator iter = selector.iterator();
Iterator<XdmItem> iter = selector.iterator();
while (iter.hasNext()) {
XdmItem item = (XdmItem) iter.next();
XdmItem item = iter.next();
XdmNode node = null;
try {
node = (XdmNode) item;
@@ -97,7 +97,7 @@ public void run() throws SaxonApiException {
XdmNode doc = source.read();
pos++;
Item item = null;
Item<?> item = null;
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
@@ -140,7 +140,7 @@ public void run() throws SaxonApiException {
// Then evaluate the expression by calling iterate() on the
// net.sf.saxon.sxpath.XPathExpression object.
SequenceIterator results = xexpr.iterate(xdc);
SequenceIterator<?> results = xexpr.iterate(xdc);
// FIXME: What if the expression returns a sequence?
item = results.next();
} catch (XPathException xe) {
@@ -195,9 +195,9 @@ public void processText(XdmNode node) throws SaxonApiException {
if (parent.getNodeKind() == XdmNodeKind.ELEMENT) {
NodeInfo inode = parent.getUnderlyingNode();
InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode);
Iterator<String> prefixes = inscopeNS.iteratePrefixes();
Iterator<?> prefixes = inscopeNS.iteratePrefixes();
while (prefixes.hasNext()) {
String nspfx = prefixes.next();
String nspfx = (String)prefixes.next();
String nsuri = inscopeNS.getURIForPrefix(nspfx, true);
nsbindings.put(nspfx,nsuri);
}
@@ -75,7 +75,7 @@
private static final QName _line = new QName("line");
private static final QName _column = new QName("column");
private static final Class [] paramTypes = new Class [] {};
private static final Class<?>[] paramTypes = new Class<?>[] {};
private ReadablePipe source = null;
private ReadablePipe schemas = null;
private WritablePipe result = null;
@@ -136,7 +136,7 @@ private void runAdjacent() throws SaxonApiException {
XdmNode node = source.read();
pos++;
Item item = null;
Item<?> item = null;
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
@@ -179,7 +179,7 @@ private void runAdjacent() throws SaxonApiException {
// Then evaluate the expression by calling iterate() on the
// net.sf.saxon.sxpath.XPathExpression object.
SequenceIterator results = xexpr.iterate(xdc);
SequenceIterator<?> results = xexpr.iterate(xdc);
item = results.next();
if (item == null) {
Oops, something went wrong.

0 comments on commit 967351f

Please sign in to comment.