bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
public boolean atomicChangeObjectColor(Object dst, int oldColor, int newColor) { final Address addr = ObjectReference.fromObject(dst).toAddress().add( flagsOffset); int oldValue; int newValue; do { oldValue = addr.prepareInt(); if ((oldValue & ObjectFlags.GC_COLOUR_MASK) != oldColor) { return false; } newValue = (oldValue & ~ObjectFlags.GC_COLOUR_MASK) | newColor; } while (!addr.attempt(oldValue, newValue)); return true; }
|
public boolean atomicChangeObjectColor(Object dst, int oldColor, int newColor) { final Address addr = ObjectReference.fromObject(dst).toAddress().add( flagsOffset); int oldValue; int newValue; do { oldValue = addr.prepareInt(); if ((oldValue & ObjectFlags.GC_COLOUR_MASK) != oldColor) { return false; } newValue = (oldValue & ~ObjectFlags.GC_COLOUR_MASK) | newColor; } while (!addr.attempt(oldValue, newValue)); return true; }
| 15,287
|
public final Monitor getInflatedMonitor(Object object, VmArchitecture arch) { return MonitorManager.getInflatedMonitor(object, arch); }
|
public final Monitor getInflatedMonitor(Object object, VmArchitecture arch) { return MonitorManager.getInflatedMonitor(object); }
| 15,288
|
public int hashCode () { // FIXME: Check what SUN calculates here. return super.hashCode (); }
|
public int hashCode () { // FIXME: Check what SUN calculates here. int hashCode = Float.floatToIntBits(get(position())) + 31; int multiplier = 1; for (int i = position() + 1; i < limit(); ++i) { multiplier *= 31; hashCode += (Float.floatToIntBits(get(i)) + 30)*multiplier; } return hashCode; }
| 15,289
|
final public static FloatBuffer wrap (float[] array, int offset, int length) { return new FloatBufferImpl (array, 0, array.length, offset + length, offset, -1, false); }
|
public static final FloatBuffer wrap (float[] array, int offset, int length) { return new FloatBufferImpl (array, 0, array.length, offset + length, offset, -1, false); }
| 15,290
|
public static float[] RGBtoHSB(int red, int green, int blue, float array[]) { if (array == null) array = new float[3]; // Calculate brightness. int min; int max; if (red < green) { min = red; max = green; } else { min = green; max = red; } if (blue > max) max = blue; else if (blue < min) min = blue; array[2] = max / 255f; // Calculate saturation. if (max == 0) array[1] = 0; else array[1] = (max - min) / max; // Calculate hue. if (array[1] == 0) array[0] = 0; else { float delta = (max - min) * 6; if (red == max) array[0] = (green - blue) / delta; else if (green == max) array[0] = 1f / 3 + (blue - red) / delta; else array[0] = 2f / 3 + (red - green) / delta; if (array[0] < 0) array[0]++; } return array; }
|
public static float[] RGBtoHSB(int red, int green, int blue, float array[]) { if (array == null) array = new float[3]; // Calculate brightness. int min; int max; if (red < green) { min = red; max = green; } else { min = green; max = red; } if (blue > max) max = blue; else if (blue < min) min = blue; array[2] = max / 255f; // Calculate saturation. if (max == 0) array[1] = 0; else array[1] = ((float) (max - min)) / ((float) max); // Calculate hue. if (array[1] == 0) array[0] = 0; else { float delta = (max - min) * 6; if (red == max) array[0] = (green - blue) / delta; else if (green == max) array[0] = 1f / 3 + (blue - red) / delta; else array[0] = 2f / 3 + (red - green) / delta; if (array[0] < 0) array[0]++; } return array; }
| 15,291
|
public File resolveFile(String fileName) throws FileNotFoundException { if (directoryList == null){ File file = new File(fileName); if(file.exists()) { System.out.println("Resolved: " + file); return file; } else { throw new FileNotFoundException(fileName); } } else { File resolved; for (File directory : directoryList) { resolved = new File(directory, fileName); if (resolved.exists()){ System.out.println("Resolved: " + resolved); return resolved; } } } throw new FileNotFoundException(fileName); }
|
public File resolveFile(String fileName) throws FileNotFoundException { if (directoryList == null){ File file = new File(fileName); if(file.exists()) { return file; } else { throw new FileNotFoundException(fileName); } } else { File resolved; for (File directory : directoryList) { resolved = new File(directory, fileName); if (resolved.exists()){ System.out.println("Resolved: " + resolved); return resolved; } } } throw new FileNotFoundException(fileName); }
| 15,292
|
public File resolveFile(String fileName) throws FileNotFoundException { if (directoryList == null){ File file = new File(fileName); if(file.exists()) { System.out.println("Resolved: " + file); return file; } else { throw new FileNotFoundException(fileName); } } else { File resolved; for (File directory : directoryList) { resolved = new File(directory, fileName); if (resolved.exists()){ System.out.println("Resolved: " + resolved); return resolved; } } } throw new FileNotFoundException(fileName); }
|
public File resolveFile(String fileName) throws FileNotFoundException { if (directoryList == null){ File file = new File(fileName); if(file.exists()) { System.out.println("Resolved: " + file); return file; } else { throw new FileNotFoundException(fileName); } } else { File resolved; for (File directory : directoryList) { resolved = new File(directory, fileName); if (resolved.exists()){ return resolved; } } } throw new FileNotFoundException(fileName); }
| 15,293
|
public AccessibleJPanel() { // Nothing to do here. }
|
protected AccessibleJPanel() { // Nothing to do here. }
| 15,294
|
Stylesheet(TransformerFactoryImpl factory, Stylesheet parent, Document doc, String systemId, int precedence) throws TransformerConfigurationException { this.factory = factory; this.systemId = systemId; this.precedence = precedence; this.parent = parent; extensionElementPrefixes = new HashSet(); excludeResultPrefixes = new HashSet(); stripSpace = new LinkedHashSet(); preserveSpace = new LinkedHashSet(); outputCdataSectionElements = new LinkedHashSet(); xpath = (XPathImpl) factory.xpathFactory.newXPath(); if (parent == null) { bindings = new Bindings(this); attributeSets = new LinkedList(); variables = new LinkedList(); namespaceAliases = new LinkedHashMap(); templates = new LinkedList(); keys = new LinkedList(); decimalFormats = new LinkedHashMap(); initDefaultDecimalFormat(); xpath.setNamespaceContext(this); xpath.setXPathFunctionResolver(this); } else { /* Test for import circularity */ for (Stylesheet ctx = this; ctx.parent != null; ctx = ctx.parent) { if (systemId != null && systemId.equals(ctx.parent.systemId)) { String msg = "circularity importing " + systemId; throw new TransformerConfigurationException(msg); } } /* OK */ Stylesheet root = getRootStylesheet(); bindings = root.bindings; attributeSets = root.attributeSets; variables = root.variables; namespaceAliases = root.namespaceAliases; templates = root.templates; keys = root.keys; decimalFormats = root.decimalFormats; xpath.setNamespaceContext(root); xpath.setXPathFunctionResolver(root); } xpath.setXPathVariableResolver(bindings); Test anyNode = new NodeTypeTest((short) 0); List tests = Collections.singletonList(anyNode); builtInNodeTemplate = new ApplyTemplatesNode(new Selector(Selector.CHILD, tests), null, null, null, true); builtInTextTemplate = new ValueOfNode(new Selector(Selector.SELF, tests), false); parse(doc.getDocumentElement(), true); current = doc; // Alow namespace resolution during processing debug = ("yes".equals(System.getProperty("xsl.debug"))); if (debug) { System.err.println("Stylesheet: " + doc.getDocumentURI()); for (Iterator i = templates.iterator(); i.hasNext(); ) { Template t = (Template) i.next(); t.list(System.err); System.err.println("--------------------"); } } }
|
Stylesheet(TransformerFactoryImpl factory, Stylesheet parent, Document doc, String systemId, int precedence) throws TransformerConfigurationException { this.factory = factory; this.systemId = systemId; this.precedence = precedence; this.parent = parent; extensionElementPrefixes = new HashSet(); excludeResultPrefixes = new HashSet(); stripSpace = new LinkedHashSet(); preserveSpace = new LinkedHashSet(); outputCdataSectionElements = new LinkedHashSet(); xpath = (XPathImpl) factory.xpathFactory.newXPath(); if (parent == null) { bindings = new Bindings(this); attributeSets = new LinkedList(); variables = new LinkedList(); namespaceAliases = new LinkedHashMap(); templates = new LinkedList(); keys = new LinkedList(); decimalFormats = new LinkedHashMap(); initDefaultDecimalFormat(); xpath.setXPathFunctionResolver(this); } else { /* Test for import circularity */ for (Stylesheet ctx = this; ctx.parent != null; ctx = ctx.parent) { if (systemId != null && systemId.equals(ctx.parent.systemId)) { String msg = "circularity importing " + systemId; throw new TransformerConfigurationException(msg); } } /* OK */ Stylesheet root = getRootStylesheet(); bindings = root.bindings; attributeSets = root.attributeSets; variables = root.variables; namespaceAliases = root.namespaceAliases; templates = root.templates; keys = root.keys; decimalFormats = root.decimalFormats; xpath.setNamespaceContext(root); xpath.setXPathFunctionResolver(root); } xpath.setXPathVariableResolver(bindings); Test anyNode = new NodeTypeTest((short) 0); List tests = Collections.singletonList(anyNode); builtInNodeTemplate = new ApplyTemplatesNode(new Selector(Selector.CHILD, tests), null, null, null, true); builtInTextTemplate = new ValueOfNode(new Selector(Selector.SELF, tests), false); parse(doc.getDocumentElement(), true); current = doc; // Alow namespace resolution during processing debug = ("yes".equals(System.getProperty("xsl.debug"))); if (debug) { System.err.println("Stylesheet: " + doc.getDocumentURI()); for (Iterator i = templates.iterator(); i.hasNext(); ) { Template t = (Template) i.next(); t.list(System.err); System.err.println("--------------------"); } } }
| 15,295
|
Stylesheet(TransformerFactoryImpl factory, Stylesheet parent, Document doc, String systemId, int precedence) throws TransformerConfigurationException { this.factory = factory; this.systemId = systemId; this.precedence = precedence; this.parent = parent; extensionElementPrefixes = new HashSet(); excludeResultPrefixes = new HashSet(); stripSpace = new LinkedHashSet(); preserveSpace = new LinkedHashSet(); outputCdataSectionElements = new LinkedHashSet(); xpath = (XPathImpl) factory.xpathFactory.newXPath(); if (parent == null) { bindings = new Bindings(this); attributeSets = new LinkedList(); variables = new LinkedList(); namespaceAliases = new LinkedHashMap(); templates = new LinkedList(); keys = new LinkedList(); decimalFormats = new LinkedHashMap(); initDefaultDecimalFormat(); xpath.setNamespaceContext(this); xpath.setXPathFunctionResolver(this); } else { /* Test for import circularity */ for (Stylesheet ctx = this; ctx.parent != null; ctx = ctx.parent) { if (systemId != null && systemId.equals(ctx.parent.systemId)) { String msg = "circularity importing " + systemId; throw new TransformerConfigurationException(msg); } } /* OK */ Stylesheet root = getRootStylesheet(); bindings = root.bindings; attributeSets = root.attributeSets; variables = root.variables; namespaceAliases = root.namespaceAliases; templates = root.templates; keys = root.keys; decimalFormats = root.decimalFormats; xpath.setNamespaceContext(root); xpath.setXPathFunctionResolver(root); } xpath.setXPathVariableResolver(bindings); Test anyNode = new NodeTypeTest((short) 0); List tests = Collections.singletonList(anyNode); builtInNodeTemplate = new ApplyTemplatesNode(new Selector(Selector.CHILD, tests), null, null, null, true); builtInTextTemplate = new ValueOfNode(new Selector(Selector.SELF, tests), false); parse(doc.getDocumentElement(), true); current = doc; // Alow namespace resolution during processing debug = ("yes".equals(System.getProperty("xsl.debug"))); if (debug) { System.err.println("Stylesheet: " + doc.getDocumentURI()); for (Iterator i = templates.iterator(); i.hasNext(); ) { Template t = (Template) i.next(); t.list(System.err); System.err.println("--------------------"); } } }
|
Stylesheet(TransformerFactoryImpl factory, Stylesheet parent, Document doc, String systemId, int precedence) throws TransformerConfigurationException { this.factory = factory; this.systemId = systemId; this.precedence = precedence; this.parent = parent; extensionElementPrefixes = new HashSet(); excludeResultPrefixes = new HashSet(); stripSpace = new LinkedHashSet(); preserveSpace = new LinkedHashSet(); outputCdataSectionElements = new LinkedHashSet(); xpath = (XPathImpl) factory.xpathFactory.newXPath(); if (parent == null) { bindings = new Bindings(this); attributeSets = new LinkedList(); variables = new LinkedList(); namespaceAliases = new LinkedHashMap(); templates = new LinkedList(); keys = new LinkedList(); decimalFormats = new LinkedHashMap(); initDefaultDecimalFormat(); xpath.setNamespaceContext(this); xpath.setXPathFunctionResolver(this); } else { /* Test for import circularity */ for (Stylesheet ctx = this; ctx.parent != null; ctx = ctx.parent) { if (systemId != null && systemId.equals(ctx.parent.systemId)) { String msg = "circularity importing " + systemId; throw new TransformerConfigurationException(msg); } } /* OK */ Stylesheet root = getRootStylesheet(); bindings = root.bindings; attributeSets = root.attributeSets; variables = root.variables; namespaceAliases = root.namespaceAliases; templates = root.templates; keys = root.keys; decimalFormats = root.decimalFormats; xpath.setXPathFunctionResolver(root); } xpath.setXPathVariableResolver(bindings); Test anyNode = new NodeTypeTest((short) 0); List tests = Collections.singletonList(anyNode); builtInNodeTemplate = new ApplyTemplatesNode(new Selector(Selector.CHILD, tests), null, null, null, true); builtInTextTemplate = new ValueOfNode(new Selector(Selector.SELF, tests), false); parse(doc.getDocumentElement(), true); current = doc; // Alow namespace resolution during processing debug = ("yes".equals(System.getProperty("xsl.debug"))); if (debug) { System.err.println("Stylesheet: " + doc.getDocumentURI()); for (Iterator i = templates.iterator(); i.hasNext(); ) { Template t = (Template) i.next(); t.list(System.err); System.err.println("--------------------"); } } }
| 15,296
|
final void addNamespaceNodes(Node source, Node target, Document doc, Collection elementExcludeResultPrefixes) { NamedNodeMap attrs = source.getAttributes(); if (attrs != null) { int len = attrs.getLength(); for (int i = 0; i < len; i++) { Node attr = attrs.item(i); String uri = attr.getNamespaceURI(); if (uri == XMLConstants.XMLNS_ATTRIBUTE_NS_URI) { String prefix = attr.getLocalName(); if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { prefix = "#default"; } String ns = attr.getNodeValue(); // Should the namespace be excluded? if (XSL_NS.equals(ns) || extensionElementPrefixes.contains(prefix) || elementExcludeResultPrefixes.contains(prefix) || excludeResultPrefixes.contains(prefix)) { continue; } // Is the namespace already defined on the target? if (prefix == "#default") { prefix = null; } if (target.lookupNamespaceURI(prefix) != null) { continue; } attr = attr.cloneNode(true); attr = doc.adoptNode(attr); target.getAttributes().setNamedItemNS(attr); } } } Node parent = source.getParentNode(); if (parent != null) { addNamespaceNodes(parent, target, doc, elementExcludeResultPrefixes); } }
|
final void addNamespaceNodes(Node source, Node target, Document doc, Collection elementExcludeResultPrefixes) NamedNodeMap attrs = source.getAttributes(); if (attrs != null) int len = attrs.getLength(); for (int i = 0; i < len; i++) Node attr = attrs.item(i); String uri = attr.getNamespaceURI(); if (uri == XMLConstants.XMLNS_ATTRIBUTE_NS_URI) String prefix = attr.getLocalName(); if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) prefix = "#default"; } String ns = attr.getNodeValue(); // Should the namespace be excluded? if (XSL_NS.equals(ns) || extensionElementPrefixes.contains(prefix) || elementExcludeResultPrefixes.contains(prefix) || excludeResultPrefixes.contains(prefix)) continue; } // Is the namespace already defined on the target? if (prefix == "#default") prefix = null; } if (target.lookupNamespaceURI(prefix) != null) continue; } attr = attr.cloneNode(true); attr = doc.adoptNode(attr); target.getAttributes().setNamedItemNS(attr); } } } Node parent = source.getParentNode(); if (parent != null) addNamespaceNodes(parent, target, doc, elementExcludeResultPrefixes); } }
| 15,297
|
final void addNamespaceNodes(Node source, Node target, Document doc, Collection elementExcludeResultPrefixes) { NamedNodeMap attrs = source.getAttributes(); if (attrs != null) { int len = attrs.getLength(); for (int i = 0; i < len; i++) { Node attr = attrs.item(i); String uri = attr.getNamespaceURI(); if (uri == XMLConstants.XMLNS_ATTRIBUTE_NS_URI) { String prefix = attr.getLocalName(); if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { prefix = "#default"; } String ns = attr.getNodeValue(); // Should the namespace be excluded? if (XSL_NS.equals(ns) || extensionElementPrefixes.contains(prefix) || elementExcludeResultPrefixes.contains(prefix) || excludeResultPrefixes.contains(prefix)) { continue; } // Is the namespace already defined on the target? if (prefix == "#default") { prefix = null; } if (target.lookupNamespaceURI(prefix) != null) { continue; } attr = attr.cloneNode(true); attr = doc.adoptNode(attr); target.getAttributes().setNamedItemNS(attr); } } } Node parent = source.getParentNode(); if (parent != null) { addNamespaceNodes(parent, target, doc, elementExcludeResultPrefixes); } }
|
final void addNamespaceNodes(Node source, Node target, Document doc, Collection elementExcludeResultPrefixes) { NamedNodeMap attrs = source.getAttributes(); if (attrs != null) { int len = attrs.getLength(); for (int i = 0; i < len; i++) { Node attr = attrs.item(i); String uri = attr.getNamespaceURI(); if (uri == XMLConstants.XMLNS_ATTRIBUTE_NS_URI) { String prefix = attr.getLocalName(); if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) { prefix = "#default"; String ns = attr.getNodeValue(); // Should the namespace be excluded? if (XSL_NS.equals(ns) || extensionElementPrefixes.contains(prefix) || elementExcludeResultPrefixes.contains(prefix) || excludeResultPrefixes.contains(prefix)) { continue; // Is the namespace already defined on the target? if (prefix == "#default") { prefix = null; if (target.lookupNamespaceURI(prefix) != null) { continue; attr = attr.cloneNode(true); attr = doc.adoptNode(attr); target.getAttributes().setNamedItemNS(attr); Node parent = source.getParentNode(); if (parent != null) { addNamespaceNodes(parent, target, doc, elementExcludeResultPrefixes);
| 15,298
|
void doParse(Node node, boolean root) throws TransformerConfigurationException { try { String namespaceUri = node.getNamespaceURI(); if (XSL_NS.equals(namespaceUri) && node.getNodeType() == Node.ELEMENT_NODE) { String name = node.getLocalName(); NamedNodeMap attrs = node.getAttributes(); if ("stylesheet".equals(name)) { version = getAttribute(attrs, "version"); String eep = getAttribute(attrs, "extension-element-prefixes"); if (eep != null) { StringTokenizer st = new StringTokenizer(eep); while (st.hasMoreTokens()) { extensionElementPrefixes.add(st.nextToken()); } } String erp = getAttribute(attrs, "exclude-result-prefixes"); if (erp != null) { StringTokenizer st = new StringTokenizer(erp); while (st.hasMoreTokens()) { excludeResultPrefixes.add(st.nextToken()); } } parse(node.getFirstChild(), false); } else if ("template".equals(name)) { templates.add(parseTemplate(node, attrs)); } else if ("param".equals(name) || "variable".equals(name)) { int type = "variable".equals(name) ? Bindings.VARIABLE : Bindings.PARAM; TemplateNode content = parse(node.getFirstChild()); QName paramName = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); ParameterNode param; if (select != null && select.length() > 0) { if (content != null) { String msg = "parameter '" + paramName + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); param = new ParameterNode(paramName, expr, type); } else { param = new ParameterNode(paramName, null, type); param.children = content; } variables.add(param); } else if ("include".equals(name) || "import".equals(name)) { int delta = "import".equals(name) ? -1 : 0; String href = getRequiredAttribute(attrs, "href", node); Source source; synchronized (factory.resolver) { if (transformer != null) { factory.resolver .setUserResolver(transformer.getURIResolver()); factory.resolver .setUserListener(transformer.getErrorListener()); } source = factory.resolver.resolve(systemId, href); } factory.newStylesheet(source, precedence + delta, this); } else if ("output".equals(name)) { parseOutput(node, attrs); } else if ("preserve-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { preserveSpace.add(parseNameTest(st.nextToken())); } } else if ("strip-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { stripSpace.add(parseNameTest(st.nextToken())); } } else if ("key".equals(name)) { parseKey(node, attrs); } else if ("decimal-format".equals(name)) { parseDecimalFormat(node, attrs); } else if ("namespace-alias".equals(name)) { parseNamespaceAlias(node, attrs); } else if ("attribute-set".equals(name)) { parseAttributeSet(node, attrs); } } else if (root) { // Literal document element Attr versionNode = ((Element)node).getAttributeNodeNS(XSL_NS, "version"); if (versionNode == null) { String msg = "no xsl:version attribute on literal result node"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } version = versionNode.getValue(); Node rootClone = node.cloneNode(true); NamedNodeMap attrs = rootClone.getAttributes(); attrs.removeNamedItemNS(XSL_NS, "version"); templates.add(new Template(this, null, new Root(), parse(rootClone), precedence, Template.DEFAULT_PRIORITY, null)); } else { // Skip unknown elements, text, comments, etc } } catch (TransformerException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (DOMException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (XPathExpressionException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } }
|
void doParse(Node node, boolean root) throws TransformerConfigurationException try String namespaceUri = node.getNamespaceURI(); if (XSL_NS.equals(namespaceUri) && node.getNodeType() == Node.ELEMENT_NODE) String name = node.getLocalName(); NamedNodeMap attrs = node.getAttributes(); if ("stylesheet".equals(name)) version = getAttribute(attrs, "version"); String eep = getAttribute(attrs, "extension-element-prefixes"); if (eep != null) StringTokenizer st = new StringTokenizer(eep); while (st.hasMoreTokens()) extensionElementPrefixes.add(st.nextToken()); } } String erp = getAttribute(attrs, "exclude-result-prefixes"); if (erp != null) StringTokenizer st = new StringTokenizer(erp); while (st.hasMoreTokens()) excludeResultPrefixes.add(st.nextToken()); } } parse(node.getFirstChild(), false); } else if ("template".equals(name)) templates.add(parseTemplate(node, attrs)); } else if ("param".equals(name) || "variable".equals(name)) int type = "variable".equals(name) ? Bindings.VARIABLE : Bindings.PARAM; TemplateNode content = parse(node.getFirstChild()); QName paramName = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); ParameterNode param; if (select != null && select.length() > 0) if (content != null) String msg = "parameter '" + paramName + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); param = new ParameterNode(paramName, expr, type); } else param = new ParameterNode(paramName, null, type); param.children = content; } variables.add(param); } else if ("include".equals(name) || "import".equals(name)) int delta = "import".equals(name) ? -1 : 0; String href = getRequiredAttribute(attrs, "href", node); Source source; synchronized (factory.resolver) if (transformer != null) factory.resolver .setUserResolver(transformer.getURIResolver()); factory.resolver .setUserListener(transformer.getErrorListener()); } source = factory.resolver.resolve(systemId, href); } factory.newStylesheet(source, precedence + delta, this); } else if ("output".equals(name)) parseOutput(node, attrs); } else if ("preserve-space".equals(name)) String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) preserveSpace.add(parseNameTest(st.nextToken())); } } else if ("strip-space".equals(name)) String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) stripSpace.add(parseNameTest(st.nextToken())); } } else if ("key".equals(name)) parseKey(node, attrs); } else if ("decimal-format".equals(name)) parseDecimalFormat(node, attrs); } else if ("namespace-alias".equals(name)) parseNamespaceAlias(node, attrs); } else if ("attribute-set".equals(name)) parseAttributeSet(node, attrs); } } else if (root) // Literal document element Attr versionNode = ((Element)node).getAttributeNodeNS(XSL_NS, "version"); if (versionNode == null) String msg = "no xsl:version attribute on literal result node"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } version = versionNode.getValue(); Node rootClone = node.cloneNode(true); NamedNodeMap attrs = rootClone.getAttributes(); attrs.removeNamedItemNS(XSL_NS, "version"); templates.add(new Template(this, null, new Root(), parse(rootClone), precedence, Template.DEFAULT_PRIORITY, null)); } else // Skip unknown elements, text, comments, etc } } catch (TransformerException e) DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (DOMException e) DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (XPathExpressionException e) DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } }
| 15,299
|
void doParse(Node node, boolean root) throws TransformerConfigurationException { try { String namespaceUri = node.getNamespaceURI(); if (XSL_NS.equals(namespaceUri) && node.getNodeType() == Node.ELEMENT_NODE) { String name = node.getLocalName(); NamedNodeMap attrs = node.getAttributes(); if ("stylesheet".equals(name)) { version = getAttribute(attrs, "version"); String eep = getAttribute(attrs, "extension-element-prefixes"); if (eep != null) { StringTokenizer st = new StringTokenizer(eep); while (st.hasMoreTokens()) { extensionElementPrefixes.add(st.nextToken()); } } String erp = getAttribute(attrs, "exclude-result-prefixes"); if (erp != null) { StringTokenizer st = new StringTokenizer(erp); while (st.hasMoreTokens()) { excludeResultPrefixes.add(st.nextToken()); } } parse(node.getFirstChild(), false); } else if ("template".equals(name)) { templates.add(parseTemplate(node, attrs)); } else if ("param".equals(name) || "variable".equals(name)) { int type = "variable".equals(name) ? Bindings.VARIABLE : Bindings.PARAM; TemplateNode content = parse(node.getFirstChild()); QName paramName = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); ParameterNode param; if (select != null && select.length() > 0) { if (content != null) { String msg = "parameter '" + paramName + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); param = new ParameterNode(paramName, expr, type); } else { param = new ParameterNode(paramName, null, type); param.children = content; } variables.add(param); } else if ("include".equals(name) || "import".equals(name)) { int delta = "import".equals(name) ? -1 : 0; String href = getRequiredAttribute(attrs, "href", node); Source source; synchronized (factory.resolver) { if (transformer != null) { factory.resolver .setUserResolver(transformer.getURIResolver()); factory.resolver .setUserListener(transformer.getErrorListener()); } source = factory.resolver.resolve(systemId, href); } factory.newStylesheet(source, precedence + delta, this); } else if ("output".equals(name)) { parseOutput(node, attrs); } else if ("preserve-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { preserveSpace.add(parseNameTest(st.nextToken())); } } else if ("strip-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { stripSpace.add(parseNameTest(st.nextToken())); } } else if ("key".equals(name)) { parseKey(node, attrs); } else if ("decimal-format".equals(name)) { parseDecimalFormat(node, attrs); } else if ("namespace-alias".equals(name)) { parseNamespaceAlias(node, attrs); } else if ("attribute-set".equals(name)) { parseAttributeSet(node, attrs); } } else if (root) { // Literal document element Attr versionNode = ((Element)node).getAttributeNodeNS(XSL_NS, "version"); if (versionNode == null) { String msg = "no xsl:version attribute on literal result node"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } version = versionNode.getValue(); Node rootClone = node.cloneNode(true); NamedNodeMap attrs = rootClone.getAttributes(); attrs.removeNamedItemNS(XSL_NS, "version"); templates.add(new Template(this, null, new Root(), parse(rootClone), precedence, Template.DEFAULT_PRIORITY, null)); } else { // Skip unknown elements, text, comments, etc } } catch (TransformerException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (DOMException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (XPathExpressionException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } }
|
void doParse(Node node, boolean root) throws TransformerConfigurationException { try { String namespaceUri = node.getNamespaceURI(); if (XSL_NS.equals(namespaceUri) && node.getNodeType() == Node.ELEMENT_NODE) { String name = node.getLocalName(); NamedNodeMap attrs = node.getAttributes(); if ("stylesheet".equals(name)) { version = getAttribute(attrs, "version"); String eep = getAttribute(attrs, "extension-element-prefixes"); if (eep != null) { StringTokenizer st = new StringTokenizer(eep); while (st.hasMoreTokens()) { extensionElementPrefixes.add(st.nextToken()); String erp = getAttribute(attrs, "exclude-result-prefixes"); if (erp != null) { StringTokenizer st = new StringTokenizer(erp); while (st.hasMoreTokens()) { excludeResultPrefixes.add(st.nextToken()); parse(node.getFirstChild(), false); else if ("template".equals(name)) { templates.add(parseTemplate(node, attrs)); else if ("param".equals(name) || "variable".equals(name)) { int type = "variable".equals(name) ? Bindings.VARIABLE : Bindings.PARAM; TemplateNode content = parse(node.getFirstChild()); QName paramName = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); ParameterNode param; if (select != null && select.length() > 0) { if (content != null) { String msg = "parameter '" + paramName + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); Expr expr = (Expr) xpath.compile(select); param = new ParameterNode(paramName, expr, type); else { param = new ParameterNode(paramName, null, type); param.children = content; variables.add(param); else if ("include".equals(name) || "import".equals(name)) { int delta = "import".equals(name) ? -1 : 0; String href = getRequiredAttribute(attrs, "href", node); Source source; synchronized (factory.resolver) { if (transformer != null) { factory.resolver .setUserResolver(transformer.getURIResolver()); factory.resolver .setUserListener(transformer.getErrorListener()); source = factory.resolver.resolve(systemId, href); factory.newStylesheet(source, precedence + delta, this); else if ("output".equals(name)) { parseOutput(node, attrs); else if ("preserve-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { preserveSpace.add(parseNameTest(st.nextToken())); else if ("strip-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { stripSpace.add(parseNameTest(st.nextToken())); else if ("key".equals(name)) { parseKey(node, attrs); else if ("decimal-format".equals(name)) { parseDecimalFormat(node, attrs); else if ("namespace-alias".equals(name)) { parseNamespaceAlias(node, attrs); else if ("attribute-set".equals(name)) { parseAttributeSet(node, attrs); else if (root) { // Literal document element Attr versionNode = ((Element)node).getAttributeNodeNS(XSL_NS, "version"); if (versionNode == null) { String msg = "no xsl:version attribute on literal result node"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); version = versionNode.getValue(); Node rootClone = node.cloneNode(true); NamedNodeMap attrs = rootClone.getAttributes(); attrs.removeNamedItemNS(XSL_NS, "version"); templates.add(new Template(this, null, new Root(), parse(rootClone), precedence, Template.DEFAULT_PRIORITY, null)); else { // Skip unknown elements, text, comments, etc catch (TransformerException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); catch (DOMException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); catch (XPathExpressionException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e);
| 15,300
|
void doParse(Node node, boolean root) throws TransformerConfigurationException { try { String namespaceUri = node.getNamespaceURI(); if (XSL_NS.equals(namespaceUri) && node.getNodeType() == Node.ELEMENT_NODE) { String name = node.getLocalName(); NamedNodeMap attrs = node.getAttributes(); if ("stylesheet".equals(name)) { version = getAttribute(attrs, "version"); String eep = getAttribute(attrs, "extension-element-prefixes"); if (eep != null) { StringTokenizer st = new StringTokenizer(eep); while (st.hasMoreTokens()) { extensionElementPrefixes.add(st.nextToken()); } } String erp = getAttribute(attrs, "exclude-result-prefixes"); if (erp != null) { StringTokenizer st = new StringTokenizer(erp); while (st.hasMoreTokens()) { excludeResultPrefixes.add(st.nextToken()); } } parse(node.getFirstChild(), false); } else if ("template".equals(name)) { templates.add(parseTemplate(node, attrs)); } else if ("param".equals(name) || "variable".equals(name)) { int type = "variable".equals(name) ? Bindings.VARIABLE : Bindings.PARAM; TemplateNode content = parse(node.getFirstChild()); QName paramName = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); ParameterNode param; if (select != null && select.length() > 0) { if (content != null) { String msg = "parameter '" + paramName + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); param = new ParameterNode(paramName, expr, type); } else { param = new ParameterNode(paramName, null, type); param.children = content; } variables.add(param); } else if ("include".equals(name) || "import".equals(name)) { int delta = "import".equals(name) ? -1 : 0; String href = getRequiredAttribute(attrs, "href", node); Source source; synchronized (factory.resolver) { if (transformer != null) { factory.resolver .setUserResolver(transformer.getURIResolver()); factory.resolver .setUserListener(transformer.getErrorListener()); } source = factory.resolver.resolve(systemId, href); } factory.newStylesheet(source, precedence + delta, this); } else if ("output".equals(name)) { parseOutput(node, attrs); } else if ("preserve-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { preserveSpace.add(parseNameTest(st.nextToken())); } } else if ("strip-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { stripSpace.add(parseNameTest(st.nextToken())); } } else if ("key".equals(name)) { parseKey(node, attrs); } else if ("decimal-format".equals(name)) { parseDecimalFormat(node, attrs); } else if ("namespace-alias".equals(name)) { parseNamespaceAlias(node, attrs); } else if ("attribute-set".equals(name)) { parseAttributeSet(node, attrs); } } else if (root) { // Literal document element Attr versionNode = ((Element)node).getAttributeNodeNS(XSL_NS, "version"); if (versionNode == null) { String msg = "no xsl:version attribute on literal result node"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } version = versionNode.getValue(); Node rootClone = node.cloneNode(true); NamedNodeMap attrs = rootClone.getAttributes(); attrs.removeNamedItemNS(XSL_NS, "version"); templates.add(new Template(this, null, new Root(), parse(rootClone), precedence, Template.DEFAULT_PRIORITY, null)); } else { // Skip unknown elements, text, comments, etc } } catch (TransformerException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (DOMException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (XPathExpressionException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } }
|
void doParse(Node node, boolean root) throws TransformerConfigurationException { try { String namespaceUri = node.getNamespaceURI(); if (XSL_NS.equals(namespaceUri) && node.getNodeType() == Node.ELEMENT_NODE) { String name = node.getLocalName(); NamedNodeMap attrs = node.getAttributes(); if ("stylesheet".equals(name)) { version = getAttribute(attrs, "version"); String eep = getAttribute(attrs, "extension-element-prefixes"); if (eep != null) { StringTokenizer st = new StringTokenizer(eep); while (st.hasMoreTokens()) { extensionElementPrefixes.add(st.nextToken()); } } String erp = getAttribute(attrs, "exclude-result-prefixes"); if (erp != null) { StringTokenizer st = new StringTokenizer(erp); while (st.hasMoreTokens()) { excludeResultPrefixes.add(st.nextToken()); } } parse(node.getFirstChild(), false); } else if ("template".equals(name)) { templates.add(parseTemplate(node, attrs)); } else if ("param".equals(name) || "variable".equals(name)) { int type = "variable".equals(name) ? Bindings.VARIABLE : Bindings.PARAM; TemplateNode content = parse(node.getFirstChild()); QName paramName = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); ParameterNode param; if (select != null && select.length() > 0) { if (content != null) { String msg = "parameter '" + paramName + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); param = new ParameterNode(paramName, expr, type); } else { param = new ParameterNode(paramName, null, type); param.children = content; } variables.add(param); } else if ("include".equals(name) || "import".equals(name)) { int delta = "import".equals(name) ? -1 : 0; String href = getRequiredAttribute(attrs, "href", node); Source source; synchronized (factory.resolver) { if (transformer != null) { factory.resolver .setUserResolver(transformer.getURIResolver()); factory.resolver .setUserListener(transformer.getErrorListener()); } source = factory.resolver.resolve(systemId, href); } factory.newStylesheet(source, precedence + delta, this); } else if ("output".equals(name)) { parseOutput(node, attrs); } else if ("preserve-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { NameTest element = parseNameTest(st.nextToken()); preserveSpace.add(new StrippingInstruction(element, precedence)); } } else if ("strip-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { stripSpace.add(parseNameTest(st.nextToken())); } } else if ("key".equals(name)) { parseKey(node, attrs); } else if ("decimal-format".equals(name)) { parseDecimalFormat(node, attrs); } else if ("namespace-alias".equals(name)) { parseNamespaceAlias(node, attrs); } else if ("attribute-set".equals(name)) { parseAttributeSet(node, attrs); } } else if (root) { // Literal document element Attr versionNode = ((Element)node).getAttributeNodeNS(XSL_NS, "version"); if (versionNode == null) { String msg = "no xsl:version attribute on literal result node"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } version = versionNode.getValue(); Node rootClone = node.cloneNode(true); NamedNodeMap attrs = rootClone.getAttributes(); attrs.removeNamedItemNS(XSL_NS, "version"); templates.add(new Template(this, null, new Root(), parse(rootClone), precedence, Template.DEFAULT_PRIORITY, null)); } else { // Skip unknown elements, text, comments, etc } } catch (TransformerException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (DOMException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (XPathExpressionException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } }
| 15,301
|
void doParse(Node node, boolean root) throws TransformerConfigurationException { try { String namespaceUri = node.getNamespaceURI(); if (XSL_NS.equals(namespaceUri) && node.getNodeType() == Node.ELEMENT_NODE) { String name = node.getLocalName(); NamedNodeMap attrs = node.getAttributes(); if ("stylesheet".equals(name)) { version = getAttribute(attrs, "version"); String eep = getAttribute(attrs, "extension-element-prefixes"); if (eep != null) { StringTokenizer st = new StringTokenizer(eep); while (st.hasMoreTokens()) { extensionElementPrefixes.add(st.nextToken()); } } String erp = getAttribute(attrs, "exclude-result-prefixes"); if (erp != null) { StringTokenizer st = new StringTokenizer(erp); while (st.hasMoreTokens()) { excludeResultPrefixes.add(st.nextToken()); } } parse(node.getFirstChild(), false); } else if ("template".equals(name)) { templates.add(parseTemplate(node, attrs)); } else if ("param".equals(name) || "variable".equals(name)) { int type = "variable".equals(name) ? Bindings.VARIABLE : Bindings.PARAM; TemplateNode content = parse(node.getFirstChild()); QName paramName = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); ParameterNode param; if (select != null && select.length() > 0) { if (content != null) { String msg = "parameter '" + paramName + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); param = new ParameterNode(paramName, expr, type); } else { param = new ParameterNode(paramName, null, type); param.children = content; } variables.add(param); } else if ("include".equals(name) || "import".equals(name)) { int delta = "import".equals(name) ? -1 : 0; String href = getRequiredAttribute(attrs, "href", node); Source source; synchronized (factory.resolver) { if (transformer != null) { factory.resolver .setUserResolver(transformer.getURIResolver()); factory.resolver .setUserListener(transformer.getErrorListener()); } source = factory.resolver.resolve(systemId, href); } factory.newStylesheet(source, precedence + delta, this); } else if ("output".equals(name)) { parseOutput(node, attrs); } else if ("preserve-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { preserveSpace.add(parseNameTest(st.nextToken())); } } else if ("strip-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { stripSpace.add(parseNameTest(st.nextToken())); } } else if ("key".equals(name)) { parseKey(node, attrs); } else if ("decimal-format".equals(name)) { parseDecimalFormat(node, attrs); } else if ("namespace-alias".equals(name)) { parseNamespaceAlias(node, attrs); } else if ("attribute-set".equals(name)) { parseAttributeSet(node, attrs); } } else if (root) { // Literal document element Attr versionNode = ((Element)node).getAttributeNodeNS(XSL_NS, "version"); if (versionNode == null) { String msg = "no xsl:version attribute on literal result node"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } version = versionNode.getValue(); Node rootClone = node.cloneNode(true); NamedNodeMap attrs = rootClone.getAttributes(); attrs.removeNamedItemNS(XSL_NS, "version"); templates.add(new Template(this, null, new Root(), parse(rootClone), precedence, Template.DEFAULT_PRIORITY, null)); } else { // Skip unknown elements, text, comments, etc } } catch (TransformerException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (DOMException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (XPathExpressionException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } }
|
void doParse(Node node, boolean root) throws TransformerConfigurationException { try { String namespaceUri = node.getNamespaceURI(); if (XSL_NS.equals(namespaceUri) && node.getNodeType() == Node.ELEMENT_NODE) { String name = node.getLocalName(); NamedNodeMap attrs = node.getAttributes(); if ("stylesheet".equals(name)) { version = getAttribute(attrs, "version"); String eep = getAttribute(attrs, "extension-element-prefixes"); if (eep != null) { StringTokenizer st = new StringTokenizer(eep); while (st.hasMoreTokens()) { extensionElementPrefixes.add(st.nextToken()); } } String erp = getAttribute(attrs, "exclude-result-prefixes"); if (erp != null) { StringTokenizer st = new StringTokenizer(erp); while (st.hasMoreTokens()) { excludeResultPrefixes.add(st.nextToken()); } } parse(node.getFirstChild(), false); } else if ("template".equals(name)) { templates.add(parseTemplate(node, attrs)); } else if ("param".equals(name) || "variable".equals(name)) { int type = "variable".equals(name) ? Bindings.VARIABLE : Bindings.PARAM; TemplateNode content = parse(node.getFirstChild()); QName paramName = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); ParameterNode param; if (select != null && select.length() > 0) { if (content != null) { String msg = "parameter '" + paramName + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); param = new ParameterNode(paramName, expr, type); } else { param = new ParameterNode(paramName, null, type); param.children = content; } variables.add(param); } else if ("include".equals(name) || "import".equals(name)) { int delta = "import".equals(name) ? -1 : 0; String href = getRequiredAttribute(attrs, "href", node); Source source; synchronized (factory.resolver) { if (transformer != null) { factory.resolver .setUserResolver(transformer.getURIResolver()); factory.resolver .setUserListener(transformer.getErrorListener()); } source = factory.resolver.resolve(systemId, href); } factory.newStylesheet(source, precedence + delta, this); } else if ("output".equals(name)) { parseOutput(node, attrs); } else if ("preserve-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { preserveSpace.add(parseNameTest(st.nextToken())); } } else if ("strip-space".equals(name)) { String elements = getRequiredAttribute(attrs, "elements", node); StringTokenizer st = new StringTokenizer(elements, " \t\n\r"); while (st.hasMoreTokens()) { NameTest element = parseNameTest(st.nextToken()); stripSpace.add(new StrippingInstruction(element, precedence)); } } else if ("key".equals(name)) { parseKey(node, attrs); } else if ("decimal-format".equals(name)) { parseDecimalFormat(node, attrs); } else if ("namespace-alias".equals(name)) { parseNamespaceAlias(node, attrs); } else if ("attribute-set".equals(name)) { parseAttributeSet(node, attrs); } } else if (root) { // Literal document element Attr versionNode = ((Element)node).getAttributeNodeNS(XSL_NS, "version"); if (versionNode == null) { String msg = "no xsl:version attribute on literal result node"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } version = versionNode.getValue(); Node rootClone = node.cloneNode(true); NamedNodeMap attrs = rootClone.getAttributes(); attrs.removeNamedItemNS(XSL_NS, "version"); templates.add(new Template(this, null, new Root(), parse(rootClone), precedence, Template.DEFAULT_PRIORITY, null)); } else { // Skip unknown elements, text, comments, etc } } catch (TransformerException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (DOMException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } catch (XPathExpressionException e) { DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(e.getMessage(), l, e); } }
| 15,302
|
static final String getAttribute(NamedNodeMap attrs, String name) { Node attr = attrs.getNamedItem(name); if (attr == null) { return null; } String ret = attr.getNodeValue(); if (ret.length() == 0) { return null; } return ret; }
|
static final String getAttribute(NamedNodeMap attrs, String name) Node attr = attrs.getNamedItem(name); if (attr == null) return null; } String ret = attr.getNodeValue(); if (ret.length() == 0) return null; } return ret; }
| 15,303
|
static final String getAttribute(NamedNodeMap attrs, String name) { Node attr = attrs.getNamedItem(name); if (attr == null) { return null; } String ret = attr.getNodeValue(); if (ret.length() == 0) { return null; } return ret; }
|
static final String getAttribute(NamedNodeMap attrs, String name) { Node attr = attrs.getNamedItem(name); if (attr == null) { return null; String ret = attr.getNodeValue(); if (ret.length() == 0) { return null; return ret;
| 15,304
|
Stylesheet getRootStylesheet() { Stylesheet stylesheet = this; while (stylesheet.parent != null) { stylesheet = stylesheet.parent; } return stylesheet; }
|
Stylesheet getRootStylesheet() Stylesheet stylesheet = this; while (stylesheet.parent != null) stylesheet = stylesheet.parent; } return stylesheet; }
| 15,305
|
Stylesheet getRootStylesheet() { Stylesheet stylesheet = this; while (stylesheet.parent != null) { stylesheet = stylesheet.parent; } return stylesheet; }
|
Stylesheet getRootStylesheet() { Stylesheet stylesheet = this; while (stylesheet.parent != null) { stylesheet = stylesheet.parent; return stylesheet;
| 15,306
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException if (debug) System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) if (currentTemplate == null) String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) // Apply built-in template // Current template is unchanged if (debug) System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
| 15,307
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
| 15,308
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); if (!currentTemplate.imports(t)) { isMatch = false; //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); return t.node;
| 15,309
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { if (selected == null) selected = t; else { if (t.precedence < selected.precedence || t.priority < selected.priority) continue; selected = t; } } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
| 15,310
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (selected == null) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
| 15,311
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
| 15,312
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = selected; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
| 15,313
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
|
TemplateNode getTemplate(QName mode, Node context, boolean applyImports) throws TransformerException { if (debug) { System.err.println("getTemplate: mode="+mode+" context="+context); } Set candidates = new TreeSet(); for (Iterator j = templates.iterator(); j.hasNext(); ) { Template t = (Template) j.next(); boolean isMatch = t.matches(mode, context); if (applyImports) { if (currentTemplate == null) { String msg = "current template may not be null " + "during apply-imports"; throw new TransformerException(msg); } if (!currentTemplate.imports(t)) { isMatch = false; } } //System.err.println("\t"+context+" "+t+"="+isMatch); if (isMatch) { candidates.add(t); } } //System.err.println("\tcandidates="+candidates); if (candidates.isEmpty()) { // Apply built-in template // Current template is unchanged if (debug) { System.err.println("\tbuiltInTemplate context="+context); } switch (context.getNodeType()) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.COMMENT_NODE: return builtInNodeTemplate; case Node.TEXT_NODE: case Node.ATTRIBUTE_NODE: return builtInTextTemplate; default: return null; } } else { Template t = (Template) candidates.iterator().next(); // Set current template currentTemplate = t; if (debug) { System.err.println("\ttemplate="+t+" context="+context); } return t.node; } }
| 15,314
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text, boolean source) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,315
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException // Check characters in text String value = text.getData(); if (value != null) int len = value.length(); for (int i = 0; i < len; i++) char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) boolean override = false; if (!stripSpace.isEmpty()) for (Iterator j = stripSpace.iterator(); j.hasNext(); ) NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) override = true; break; } } } if (!override) return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) if (ctx.getNodeType() == Node.ELEMENT_NODE) Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) break; } else if ("preserve".equals(xmlSpace)) return true; } else if (xmlSpace.length() > 0) String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,316
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; if (!override) { return true; // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; else if ("preserve".equals(xmlSpace)) { return true; else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; ctx = ctx.getParentNode(); return false;
| 15,317
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (source) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,318
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { boolean preserve = true; float psPriority = 0.0f, ssPriority = 0.0f; if (!stripSpace.isEmpty()) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,319
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,320
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,321
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { if (ssi != null) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,322
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,323
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,324
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (ssi != null) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,325
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { if (psi != null) { if (psi.precedence < ssi.precedence) preserve = false; else if (psPriority < ssPriority) preserve = false; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { if (psi != null) { if (psi.precedence < ssi.precedence) preserve = false; else if (psPriority < ssPriority) preserve = false; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { if (psi != null) { if (psi.precedence < ssi.precedence) preserve = false; else if (psPriority < ssPriority) preserve = false; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' if (psi != null) { if (psi.precedence < ssi.precedence) preserve = false; else if (psPriority < ssPriority) preserve = false; } } ctx = ctx.getParentNode(); } return false; }
| 15,326
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
|
boolean isPreserved(Text text) throws TransformerConfigurationException { // Check characters in text String value = text.getData(); if (value != null) { int len = value.length(); for (int i = 0; i < len; i++) { char c = value.charAt(i); if (c != 0x20 && c != 0x09 && c != 0x0a && c != 0x0d) { return true; } } } // Check parent node Node ctx = text.getParentNode(); if (!preserveSpace.isEmpty()) { for (Iterator i = preserveSpace.iterator(); i.hasNext(); ) { NameTest preserveTest = (NameTest) i.next(); if (preserveTest.matches(ctx, 1, 1)) { boolean override = false; if (!stripSpace.isEmpty()) { for (Iterator j = stripSpace.iterator(); j.hasNext(); ) { NameTest stripTest = (NameTest) j.next(); if (stripTest.matches(ctx, 1, 1)) { override = true; break; } } } if (!override) { return true; } } } } // Check whether any ancestor specified xml:space while (ctx != null) { if (ctx.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) ctx; String xmlSpace = element.getAttribute("xml:space"); if ("default".equals(xmlSpace)) { break; } else if ("preserve".equals(xmlSpace)) { return true; } else if (xmlSpace.length() > 0) { String msg = "Illegal value for xml:space: " + xmlSpace; throw new TransformerConfigurationException(msg); } else if ("text".equals(ctx.getLocalName()) && XSL_NS.equals(ctx.getNamespaceURI())) { // xsl:text implies xml:space='preserve' return true; } } ctx = ctx.getParentNode(); } return false; }
| 15,327
|
final TemplateNode parseApplyTemplates(Node node) throws TransformerConfigurationException, XPathExpressionException { NamedNodeMap attrs = node.getAttributes(); String m = getAttribute(attrs, "mode"); QName mode = (m == null) ? null : getQName(m); String s = getAttribute(attrs, "select"); if (s == null) { s = "child::node()"; } Node children = node.getFirstChild(); List sortKeys = parseSortKeys(children); List withParams = parseWithParams(children); Expr select = (Expr) xpath.compile(s); return new ApplyTemplatesNode(select, mode, sortKeys, withParams, false); }
|
final TemplateNode parseApplyTemplates(Node node) throws TransformerConfigurationException, XPathExpressionException NamedNodeMap attrs = node.getAttributes(); String m = getAttribute(attrs, "mode"); QName mode = (m == null) ? null : getQName(m); String s = getAttribute(attrs, "select"); if (s == null) s = "child::node()"; } Node children = node.getFirstChild(); List sortKeys = parseSortKeys(children); List withParams = parseWithParams(children); Expr select = (Expr) xpath.compile(s); return new ApplyTemplatesNode(select, mode, sortKeys, withParams, false); }
| 15,328
|
final TemplateNode parseApplyTemplates(Node node) throws TransformerConfigurationException, XPathExpressionException { NamedNodeMap attrs = node.getAttributes(); String m = getAttribute(attrs, "mode"); QName mode = (m == null) ? null : getQName(m); String s = getAttribute(attrs, "select"); if (s == null) { s = "child::node()"; } Node children = node.getFirstChild(); List sortKeys = parseSortKeys(children); List withParams = parseWithParams(children); Expr select = (Expr) xpath.compile(s); return new ApplyTemplatesNode(select, mode, sortKeys, withParams, false); }
|
final TemplateNode parseApplyTemplates(Node node) throws TransformerConfigurationException, XPathExpressionException { NamedNodeMap attrs = node.getAttributes(); String m = getAttribute(attrs, "mode"); QName mode = (m == null) ? null : getQName(m); String s = getAttribute(attrs, "select"); if (s == null) { s = "child::node()"; Node children = node.getFirstChild(); List sortKeys = parseSortKeys(children); List withParams = parseWithParams(children); Expr select = (Expr) xpath.compile(s); return new ApplyTemplatesNode(select, mode, sortKeys, withParams, false);
| 15,329
|
final NameTest parseNameTest(String token) { if ("*".equals(token)) { return new NameTest(null, true, true); } else if (token.endsWith(":*")) { QName qName = getQName(token.substring(0, token.length() - 2)); return new NameTest(qName, true, false); } else { QName qName = getQName(token); return new NameTest(qName, false, false); } }
|
final NameTest parseNameTest(String token) if ("*".equals(token)) return new NameTest(null, true, true); } else if (token.endsWith(":*")) QName qName = getQName(token.substring(0, token.length() - 2)); return new NameTest(qName, true, false); } else QName qName = getQName(token); return new NameTest(qName, false, false); } }
| 15,330
|
final NameTest parseNameTest(String token) { if ("*".equals(token)) { return new NameTest(null, true, true); } else if (token.endsWith(":*")) { QName qName = getQName(token.substring(0, token.length() - 2)); return new NameTest(qName, true, false); } else { QName qName = getQName(token); return new NameTest(qName, false, false); } }
|
final NameTest parseNameTest(String token) { if ("*".equals(token)) { return new NameTest(null, true, true); else if (token.endsWith(":*")) { QName qName = getQName(token.substring(0, token.length() - 2)); return new NameTest(qName, true, false); else { QName qName = getQName(token); return new NameTest(qName, false, false);
| 15,331
|
final NameTest parseNameTest(String token) { if ("*".equals(token)) { return new NameTest(null, true, true); } else if (token.endsWith(":*")) { QName qName = getQName(token.substring(0, token.length() - 2)); return new NameTest(qName, true, false); } else { QName qName = getQName(token); return new NameTest(qName, false, false); } }
|
final NameTest parseNameTest(String token) { if ("*".equals(token)) { return new NameTest(null, true, true); } else if (token.endsWith(":*")) { QName qName = getQName(token); return new NameTest(qName, true, false); } else { QName qName = getQName(token); return new NameTest(qName, false, false); } }
| 15,332
|
final void parseOutput(Node node, NamedNodeMap attrs) throws TransformerConfigurationException { output = node; String method = getAttribute(attrs, "method"); if ("xml".equals(method) || method == null) { outputMethod = OUTPUT_XML; } else if ("html".equals(method)) { outputMethod = OUTPUT_HTML; } else if ("text".equals(method)) { outputMethod = OUTPUT_TEXT; } else { String msg = "unsupported output method: " + method; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } outputPublicId = getAttribute(attrs, "public-id"); outputSystemId = getAttribute(attrs, "system-id"); outputEncoding = getAttribute(attrs, "encoding"); String indent = getAttribute(attrs, "indent"); if (indent != null) { outputIndent = "yes".equals(indent); } outputVersion = getAttribute(attrs, "version"); String omitXmlDecl = getAttribute(attrs, "omit-xml-declaration"); if (omitXmlDecl != null) { outputOmitXmlDeclaration = "yes".equals(omitXmlDecl); } String standalone = getAttribute(attrs, "standalone"); if (standalone != null) { outputStandalone = "yes".equals(standalone); } outputMediaType = getAttribute(attrs, "media-type"); String cdataSectionElements = getAttribute(attrs, "cdata-section-elements"); if (cdataSectionElements != null) { StringTokenizer st = new StringTokenizer(cdataSectionElements, " "); while (st.hasMoreTokens()) { outputCdataSectionElements.add(st.nextToken()); } } }
|
final void parseOutput(Node node, NamedNodeMap attrs) throws TransformerConfigurationException output = node; String method = getAttribute(attrs, "method"); if ("xml".equals(method) || method == null) outputMethod = OUTPUT_XML; } else if ("html".equals(method)) outputMethod = OUTPUT_HTML; } else if ("text".equals(method)) outputMethod = OUTPUT_TEXT; } else String msg = "unsupported output method: " + method; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } outputPublicId = getAttribute(attrs, "public-id"); outputSystemId = getAttribute(attrs, "system-id"); outputEncoding = getAttribute(attrs, "encoding"); String indent = getAttribute(attrs, "indent"); if (indent != null) outputIndent = "yes".equals(indent); } outputVersion = getAttribute(attrs, "version"); String omitXmlDecl = getAttribute(attrs, "omit-xml-declaration"); if (omitXmlDecl != null) outputOmitXmlDeclaration = "yes".equals(omitXmlDecl); } String standalone = getAttribute(attrs, "standalone"); if (standalone != null) outputStandalone = "yes".equals(standalone); } outputMediaType = getAttribute(attrs, "media-type"); String cdataSectionElements = getAttribute(attrs, "cdata-section-elements"); if (cdataSectionElements != null) StringTokenizer st = new StringTokenizer(cdataSectionElements, " "); while (st.hasMoreTokens()) outputCdataSectionElements.add(st.nextToken()); } } }
| 15,333
|
final void parseOutput(Node node, NamedNodeMap attrs) throws TransformerConfigurationException { output = node; String method = getAttribute(attrs, "method"); if ("xml".equals(method) || method == null) { outputMethod = OUTPUT_XML; } else if ("html".equals(method)) { outputMethod = OUTPUT_HTML; } else if ("text".equals(method)) { outputMethod = OUTPUT_TEXT; } else { String msg = "unsupported output method: " + method; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } outputPublicId = getAttribute(attrs, "public-id"); outputSystemId = getAttribute(attrs, "system-id"); outputEncoding = getAttribute(attrs, "encoding"); String indent = getAttribute(attrs, "indent"); if (indent != null) { outputIndent = "yes".equals(indent); } outputVersion = getAttribute(attrs, "version"); String omitXmlDecl = getAttribute(attrs, "omit-xml-declaration"); if (omitXmlDecl != null) { outputOmitXmlDeclaration = "yes".equals(omitXmlDecl); } String standalone = getAttribute(attrs, "standalone"); if (standalone != null) { outputStandalone = "yes".equals(standalone); } outputMediaType = getAttribute(attrs, "media-type"); String cdataSectionElements = getAttribute(attrs, "cdata-section-elements"); if (cdataSectionElements != null) { StringTokenizer st = new StringTokenizer(cdataSectionElements, " "); while (st.hasMoreTokens()) { outputCdataSectionElements.add(st.nextToken()); } } }
|
final void parseOutput(Node node, NamedNodeMap attrs) throws TransformerConfigurationException { output = node; String method = getAttribute(attrs, "method"); if ("xml".equals(method) || method == null) { outputMethod = OUTPUT_XML; else if ("html".equals(method)) { outputMethod = OUTPUT_HTML; else if ("text".equals(method)) { outputMethod = OUTPUT_TEXT; else { String msg = "unsupported output method: " + method; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); outputPublicId = getAttribute(attrs, "public-id"); outputSystemId = getAttribute(attrs, "system-id"); outputEncoding = getAttribute(attrs, "encoding"); String indent = getAttribute(attrs, "indent"); if (indent != null) { outputIndent = "yes".equals(indent); outputVersion = getAttribute(attrs, "version"); String omitXmlDecl = getAttribute(attrs, "omit-xml-declaration"); if (omitXmlDecl != null) { outputOmitXmlDeclaration = "yes".equals(omitXmlDecl); String standalone = getAttribute(attrs, "standalone"); if (standalone != null) { outputStandalone = "yes".equals(standalone); outputMediaType = getAttribute(attrs, "media-type"); String cdataSectionElements = getAttribute(attrs, "cdata-section-elements"); if (cdataSectionElements != null) { StringTokenizer st = new StringTokenizer(cdataSectionElements, " "); while (st.hasMoreTokens()) { outputCdataSectionElements.add(st.nextToken());
| 15,334
|
final void parseOutput(Node node, NamedNodeMap attrs) throws TransformerConfigurationException { output = node; String method = getAttribute(attrs, "method"); if ("xml".equals(method) || method == null) { outputMethod = OUTPUT_XML; } else if ("html".equals(method)) { outputMethod = OUTPUT_HTML; } else if ("text".equals(method)) { outputMethod = OUTPUT_TEXT; } else { String msg = "unsupported output method: " + method; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } outputPublicId = getAttribute(attrs, "public-id"); outputSystemId = getAttribute(attrs, "system-id"); outputEncoding = getAttribute(attrs, "encoding"); String indent = getAttribute(attrs, "indent"); if (indent != null) { outputIndent = "yes".equals(indent); } outputVersion = getAttribute(attrs, "version"); String omitXmlDecl = getAttribute(attrs, "omit-xml-declaration"); if (omitXmlDecl != null) { outputOmitXmlDeclaration = "yes".equals(omitXmlDecl); } String standalone = getAttribute(attrs, "standalone"); if (standalone != null) { outputStandalone = "yes".equals(standalone); } outputMediaType = getAttribute(attrs, "media-type"); String cdataSectionElements = getAttribute(attrs, "cdata-section-elements"); if (cdataSectionElements != null) { StringTokenizer st = new StringTokenizer(cdataSectionElements, " "); while (st.hasMoreTokens()) { outputCdataSectionElements.add(st.nextToken()); } } }
|
final void parseOutput(Node node, NamedNodeMap attrs) throws TransformerConfigurationException { output = node; String method = getAttribute(attrs, "method"); if ("xml".equals(method) || method == null) { outputMethod = OUTPUT_XML; } else if ("html".equals(method)) { outputMethod = OUTPUT_HTML; } else if ("text".equals(method)) { outputMethod = OUTPUT_TEXT; } else { String msg = "unsupported output method: " + method; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } outputPublicId = getAttribute(attrs, "public-id"); outputSystemId = getAttribute(attrs, "system-id"); outputEncoding = getAttribute(attrs, "encoding"); String indent = getAttribute(attrs, "indent"); if (indent != null) { outputIndent = "yes".equals(indent); } outputVersion = getAttribute(attrs, "version"); String omitXmlDecl = getAttribute(attrs, "omit-xml-declaration"); if (omitXmlDecl != null) { outputOmitXmlDeclaration = "yes".equals(omitXmlDecl); } String standalone = getAttribute(attrs, "standalone"); if (standalone != null) { outputStandalone = "yes".equals(standalone); } outputMediaType = getAttribute(attrs, "media-type"); String cdataSectionElements = getAttribute(attrs, "cdata-section-elements"); if (cdataSectionElements != null) { StringTokenizer st = new StringTokenizer(cdataSectionElements, " "); while (st.hasMoreTokens()) { outputCdataSectionElements.add(st.nextToken()); } } }
| 15,335
|
final List parseSortKeys(Node node) throws TransformerConfigurationException, XPathExpressionException { List ret = new LinkedList(); while (node != null) { String namespaceUri = node.getNamespaceURI(); if (Stylesheet.XSL_NS.equals(namespaceUri) && Node.ELEMENT_NODE == node.getNodeType() && "sort".equals(node.getLocalName())) { NamedNodeMap attrs = node.getAttributes(); String s = getAttribute(attrs, "select"); if (s == null) { s = "."; } Expr select = (Expr) xpath.compile(s); String l = getAttribute(attrs, "lang"); TemplateNode lang = (l == null) ? null : parseAttributeValueTemplate(l, node); String dt = getAttribute(attrs, "data-type"); TemplateNode dataType = (dt == null) ? null : parseAttributeValueTemplate(dt, node); String o = getAttribute(attrs, "order"); TemplateNode order = (o == null) ? null : parseAttributeValueTemplate(o, node); String co = getAttribute(attrs, "case-order"); TemplateNode caseOrder = (co == null) ? null : parseAttributeValueTemplate(co, node); ret.add(new SortKey(select, lang, dataType, order, caseOrder)); } node = node.getNextSibling(); } return ret.isEmpty() ? null : ret; }
|
final List parseSortKeys(Node node) throws TransformerConfigurationException, XPathExpressionException List ret = new LinkedList(); while (node != null) String namespaceUri = node.getNamespaceURI(); if (Stylesheet.XSL_NS.equals(namespaceUri) && Node.ELEMENT_NODE == node.getNodeType() && "sort".equals(node.getLocalName())) NamedNodeMap attrs = node.getAttributes(); String s = getAttribute(attrs, "select"); if (s == null) s = "."; } Expr select = (Expr) xpath.compile(s); String l = getAttribute(attrs, "lang"); TemplateNode lang = (l == null) ? null : parseAttributeValueTemplate(l, node); String dt = getAttribute(attrs, "data-type"); TemplateNode dataType = (dt == null) ? null : parseAttributeValueTemplate(dt, node); String o = getAttribute(attrs, "order"); TemplateNode order = (o == null) ? null : parseAttributeValueTemplate(o, node); String co = getAttribute(attrs, "case-order"); TemplateNode caseOrder = (co == null) ? null : parseAttributeValueTemplate(co, node); ret.add(new SortKey(select, lang, dataType, order, caseOrder)); } node = node.getNextSibling(); } return ret.isEmpty() ? null : ret; }
| 15,336
|
final List parseSortKeys(Node node) throws TransformerConfigurationException, XPathExpressionException { List ret = new LinkedList(); while (node != null) { String namespaceUri = node.getNamespaceURI(); if (Stylesheet.XSL_NS.equals(namespaceUri) && Node.ELEMENT_NODE == node.getNodeType() && "sort".equals(node.getLocalName())) { NamedNodeMap attrs = node.getAttributes(); String s = getAttribute(attrs, "select"); if (s == null) { s = "."; } Expr select = (Expr) xpath.compile(s); String l = getAttribute(attrs, "lang"); TemplateNode lang = (l == null) ? null : parseAttributeValueTemplate(l, node); String dt = getAttribute(attrs, "data-type"); TemplateNode dataType = (dt == null) ? null : parseAttributeValueTemplate(dt, node); String o = getAttribute(attrs, "order"); TemplateNode order = (o == null) ? null : parseAttributeValueTemplate(o, node); String co = getAttribute(attrs, "case-order"); TemplateNode caseOrder = (co == null) ? null : parseAttributeValueTemplate(co, node); ret.add(new SortKey(select, lang, dataType, order, caseOrder)); } node = node.getNextSibling(); } return ret.isEmpty() ? null : ret; }
|
final List parseSortKeys(Node node) throws TransformerConfigurationException, XPathExpressionException { List ret = new LinkedList(); while (node != null) { String namespaceUri = node.getNamespaceURI(); if (Stylesheet.XSL_NS.equals(namespaceUri) && Node.ELEMENT_NODE == node.getNodeType() && "sort".equals(node.getLocalName())) { NamedNodeMap attrs = node.getAttributes(); String s = getAttribute(attrs, "select"); if (s == null) { s = "."; Expr select = (Expr) xpath.compile(s); String l = getAttribute(attrs, "lang"); TemplateNode lang = (l == null) ? null : parseAttributeValueTemplate(l, node); String dt = getAttribute(attrs, "data-type"); TemplateNode dataType = (dt == null) ? null : parseAttributeValueTemplate(dt, node); String o = getAttribute(attrs, "order"); TemplateNode order = (o == null) ? null : parseAttributeValueTemplate(o, node); String co = getAttribute(attrs, "case-order"); TemplateNode caseOrder = (co == null) ? null : parseAttributeValueTemplate(co, node); ret.add(new SortKey(select, lang, dataType, order, caseOrder)); node = node.getNextSibling(); return ret.isEmpty() ? null : ret;
| 15,337
|
final List parseWithParams(Node node) throws TransformerConfigurationException, XPathExpressionException { List ret = new LinkedList(); while (node != null) { String namespaceUri = node.getNamespaceURI(); if (Stylesheet.XSL_NS.equals(namespaceUri) && Node.ELEMENT_NODE == node.getNodeType() && "with-param".equals(node.getLocalName())) { NamedNodeMap attrs = node.getAttributes(); TemplateNode content = parse(node.getFirstChild()); QName name = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); if (select != null) { if (content != null) { String msg = "parameter '" + name + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); ret.add(new WithParam(name, expr)); } else { ret.add(new WithParam(name, content)); } } node = node.getNextSibling(); } return ret.isEmpty() ? null : ret; }
|
final List parseWithParams(Node node) throws TransformerConfigurationException, XPathExpressionException List ret = new LinkedList(); while (node != null) String namespaceUri = node.getNamespaceURI(); if (Stylesheet.XSL_NS.equals(namespaceUri) && Node.ELEMENT_NODE == node.getNodeType() && "with-param".equals(node.getLocalName())) NamedNodeMap attrs = node.getAttributes(); TemplateNode content = parse(node.getFirstChild()); QName name = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); if (select != null) if (content != null) String msg = "parameter '" + name + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); ret.add(new WithParam(name, expr)); } else ret.add(new WithParam(name, content)); } } node = node.getNextSibling(); } return ret.isEmpty() ? null : ret; }
| 15,338
|
final List parseWithParams(Node node) throws TransformerConfigurationException, XPathExpressionException { List ret = new LinkedList(); while (node != null) { String namespaceUri = node.getNamespaceURI(); if (Stylesheet.XSL_NS.equals(namespaceUri) && Node.ELEMENT_NODE == node.getNodeType() && "with-param".equals(node.getLocalName())) { NamedNodeMap attrs = node.getAttributes(); TemplateNode content = parse(node.getFirstChild()); QName name = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); if (select != null) { if (content != null) { String msg = "parameter '" + name + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); } Expr expr = (Expr) xpath.compile(select); ret.add(new WithParam(name, expr)); } else { ret.add(new WithParam(name, content)); } } node = node.getNextSibling(); } return ret.isEmpty() ? null : ret; }
|
final List parseWithParams(Node node) throws TransformerConfigurationException, XPathExpressionException { List ret = new LinkedList(); while (node != null) { String namespaceUri = node.getNamespaceURI(); if (Stylesheet.XSL_NS.equals(namespaceUri) && Node.ELEMENT_NODE == node.getNodeType() && "with-param".equals(node.getLocalName())) { NamedNodeMap attrs = node.getAttributes(); TemplateNode content = parse(node.getFirstChild()); QName name = getQName(getRequiredAttribute(attrs, "name", node)); String select = getAttribute(attrs, "select"); if (select != null) { if (content != null) { String msg = "parameter '" + name + "' has both select and content"; DOMSourceLocator l = new DOMSourceLocator(node); throw new TransformerConfigurationException(msg, l); Expr expr = (Expr) xpath.compile(select); ret.add(new WithParam(name, expr)); else { ret.add(new WithParam(name, content)); node = node.getNextSibling(); return ret.isEmpty() ? null : ret;
| 15,339
|
public XPathFunction resolveFunction(QName name, int arity) { String uri = name.getNamespaceURI(); if (XSL_NS.equals(uri) || uri == null || uri.length() == 0) { String localName = name.getLocalPart(); if ("document".equals(localName) && (arity == 1 || arity == 2)) { if (current == null) { throw new RuntimeException("current is null"); } return new DocumentFunction(getRootStylesheet(), current); } else if ("key".equals(localName) && (arity == 2)) { return new KeyFunction(getRootStylesheet()); } else if ("format-number".equals(localName) && (arity == 2 || arity == 3)) { return new FormatNumberFunction(getRootStylesheet()); } else if ("current".equals(localName) && (arity == 0)) { return new CurrentFunction(getRootStylesheet()); } else if ("unparsed-entity-uri".equals(localName) && (arity == 1)) { return new UnparsedEntityUriFunction(); } else if ("generate-id".equals(localName) && (arity == 1 || arity == 0)) { return new GenerateIdFunction(); } else if ("system-property".equals(localName) && (arity == 1)) { return new SystemPropertyFunction(); } else if ("element-available".equals(localName) && (arity == 1)) { return new ElementAvailableFunction(this); } else if ("function-available".equals(localName) && (arity == 1)) { return new FunctionAvailableFunction(this); } } return null; }
|
public XPathFunction resolveFunction(QName name, int arity) String uri = name.getNamespaceURI(); if (XSL_NS.equals(uri) || uri == null || uri.length() == 0) String localName = name.getLocalPart(); if ("document".equals(localName) && (arity == 1 || arity == 2)) if (current == null) throw new RuntimeException("current is null"); } return new DocumentFunction(getRootStylesheet(), current); } else if ("key".equals(localName) && (arity == 2)) return new KeyFunction(getRootStylesheet()); } else if ("format-number".equals(localName) && (arity == 2 || arity == 3)) return new FormatNumberFunction(getRootStylesheet()); } else if ("current".equals(localName) && (arity == 0)) return new CurrentFunction(getRootStylesheet()); } else if ("unparsed-entity-uri".equals(localName) && (arity == 1)) return new UnparsedEntityUriFunction(); } else if ("generate-id".equals(localName) && (arity == 1 || arity == 0)) return new GenerateIdFunction(); } else if ("system-property".equals(localName) && (arity == 1)) return new SystemPropertyFunction(); } else if ("element-available".equals(localName) && (arity == 1)) return new ElementAvailableFunction(this); } else if ("function-available".equals(localName) && (arity == 1)) return new FunctionAvailableFunction(this); } } return null; }
| 15,340
|
public XPathFunction resolveFunction(QName name, int arity) { String uri = name.getNamespaceURI(); if (XSL_NS.equals(uri) || uri == null || uri.length() == 0) { String localName = name.getLocalPart(); if ("document".equals(localName) && (arity == 1 || arity == 2)) { if (current == null) { throw new RuntimeException("current is null"); } return new DocumentFunction(getRootStylesheet(), current); } else if ("key".equals(localName) && (arity == 2)) { return new KeyFunction(getRootStylesheet()); } else if ("format-number".equals(localName) && (arity == 2 || arity == 3)) { return new FormatNumberFunction(getRootStylesheet()); } else if ("current".equals(localName) && (arity == 0)) { return new CurrentFunction(getRootStylesheet()); } else if ("unparsed-entity-uri".equals(localName) && (arity == 1)) { return new UnparsedEntityUriFunction(); } else if ("generate-id".equals(localName) && (arity == 1 || arity == 0)) { return new GenerateIdFunction(); } else if ("system-property".equals(localName) && (arity == 1)) { return new SystemPropertyFunction(); } else if ("element-available".equals(localName) && (arity == 1)) { return new ElementAvailableFunction(this); } else if ("function-available".equals(localName) && (arity == 1)) { return new FunctionAvailableFunction(this); } } return null; }
|
public XPathFunction resolveFunction(QName name, int arity) { String uri = name.getNamespaceURI(); if (XSL_NS.equals(uri) || uri == null || uri.length() == 0) { String localName = name.getLocalPart(); if ("document".equals(localName) && (arity == 1 || arity == 2)) { if (current == null) { throw new RuntimeException("current is null"); return new DocumentFunction(getRootStylesheet(), current); else if ("key".equals(localName) && (arity == 2)) { return new KeyFunction(getRootStylesheet()); else if ("format-number".equals(localName) && (arity == 2 || arity == 3)) { return new FormatNumberFunction(getRootStylesheet()); else if ("current".equals(localName) && (arity == 0)) { return new CurrentFunction(getRootStylesheet()); else if ("unparsed-entity-uri".equals(localName) && (arity == 1)) { return new UnparsedEntityUriFunction(); else if ("generate-id".equals(localName) && (arity == 1 || arity == 0)) { return new GenerateIdFunction(); else if ("system-property".equals(localName) && (arity == 1)) { return new SystemPropertyFunction(); else if ("element-available".equals(localName) && (arity == 1)) { return new ElementAvailableFunction(this); else if ("function-available".equals(localName) && (arity == 1)) { return new FunctionAvailableFunction(this); return null;
| 15,341
|
public XPathFunction resolveFunction(QName name, int arity) { String uri = name.getNamespaceURI(); if (XSL_NS.equals(uri) || uri == null || uri.length() == 0) { String localName = name.getLocalPart(); if ("document".equals(localName) && (arity == 1 || arity == 2)) { if (current == null) { throw new RuntimeException("current is null"); } return new DocumentFunction(getRootStylesheet(), current); } else if ("key".equals(localName) && (arity == 2)) { return new KeyFunction(getRootStylesheet()); } else if ("format-number".equals(localName) && (arity == 2 || arity == 3)) { return new FormatNumberFunction(getRootStylesheet()); } else if ("current".equals(localName) && (arity == 0)) { return new CurrentFunction(getRootStylesheet()); } else if ("unparsed-entity-uri".equals(localName) && (arity == 1)) { return new UnparsedEntityUriFunction(); } else if ("generate-id".equals(localName) && (arity == 1 || arity == 0)) { return new GenerateIdFunction(); } else if ("system-property".equals(localName) && (arity == 1)) { return new SystemPropertyFunction(); } else if ("element-available".equals(localName) && (arity == 1)) { return new ElementAvailableFunction(this); } else if ("function-available".equals(localName) && (arity == 1)) { return new FunctionAvailableFunction(this); } } return null; }
|
public XPathFunction resolveFunction(QName name, int arity) { String uri = name.getNamespaceURI(); if (XSL_NS.equals(uri) || uri == null || uri.length() == 0) { String localName = name.getLocalPart(); if ("document".equals(localName) && (arity == 1 || arity == 2)) { if (current == null) { throw new RuntimeException("current is null"); } return new DocumentFunction(getRootStylesheet(), current); } else if ("key".equals(localName) && (arity == 2)) { return new KeyFunction(getRootStylesheet()); } else if ("format-number".equals(localName) && (arity == 2 || arity == 3)) { return new FormatNumberFunction(getRootStylesheet()); } else if ("current".equals(localName) && (arity == 0)) { return new CurrentFunction(getRootStylesheet()); } else if ("unparsed-entity-uri".equals(localName) && (arity == 1)) { return new UnparsedEntityUriFunction(); } else if ("generate-id".equals(localName) && (arity == 1 || arity == 0)) { return new GenerateIdFunction(); } else if ("system-property".equals(localName) && (arity == 1)) { return new SystemPropertyFunction(); } else if ("element-available".equals(localName) && (arity == 1)) { return new ElementAvailableFunction(this); } else if ("function-available".equals(localName) && (arity == 1)) { return new FunctionAvailableFunction(this); } } return null; }
| 15,342
|
public XPathFunction resolveFunction(QName name, int arity) { String uri = name.getNamespaceURI(); if (XSL_NS.equals(uri) || uri == null || uri.length() == 0) { String localName = name.getLocalPart(); if ("document".equals(localName) && (arity == 1 || arity == 2)) { if (current == null) { throw new RuntimeException("current is null"); } return new DocumentFunction(getRootStylesheet(), current); } else if ("key".equals(localName) && (arity == 2)) { return new KeyFunction(getRootStylesheet()); } else if ("format-number".equals(localName) && (arity == 2 || arity == 3)) { return new FormatNumberFunction(getRootStylesheet()); } else if ("current".equals(localName) && (arity == 0)) { return new CurrentFunction(getRootStylesheet()); } else if ("unparsed-entity-uri".equals(localName) && (arity == 1)) { return new UnparsedEntityUriFunction(); } else if ("generate-id".equals(localName) && (arity == 1 || arity == 0)) { return new GenerateIdFunction(); } else if ("system-property".equals(localName) && (arity == 1)) { return new SystemPropertyFunction(); } else if ("element-available".equals(localName) && (arity == 1)) { return new ElementAvailableFunction(this); } else if ("function-available".equals(localName) && (arity == 1)) { return new FunctionAvailableFunction(this); } } return null; }
|
public XPathFunction resolveFunction(QName name, int arity) { String uri = name.getNamespaceURI(); if (XSL_NS.equals(uri) || uri == null || uri.length() == 0) { String localName = name.getLocalPart(); if ("document".equals(localName) && (arity == 1 || arity == 2)) { if (current == null) { throw new RuntimeException("current is null"); } return new DocumentFunction(getRootStylesheet(), current); } else if ("key".equals(localName) && (arity == 2)) { return new KeyFunction(getRootStylesheet()); } else if ("format-number".equals(localName) && (arity == 2 || arity == 3)) { return new FormatNumberFunction(getRootStylesheet()); } else if ("current".equals(localName) && (arity == 0)) { return new CurrentFunction(getRootStylesheet()); } else if ("unparsed-entity-uri".equals(localName) && (arity == 1)) { return new UnparsedEntityUriFunction(); } else if ("generate-id".equals(localName) && (arity == 1 || arity == 0)) { return new GenerateIdFunction(); } else if ("system-property".equals(localName) && (arity == 1)) { return new SystemPropertyFunction(); } else if ("element-available".equals(localName) && (arity == 1)) { return new ElementAvailableFunction(this); } else if ("function-available".equals(localName) && (arity == 1)) { return new FunctionAvailableFunction(this); } } return null; }
| 15,343
|
private static final BigInteger add(int x, int y) { return BigInteger.make((long) x + (long) y); }
|
private static final BigInteger add(int x, int y) { return valueOf((long) x + (long) y); }
| 15,344
|
private static BigInteger alloc(int nwords) { if (nwords <= 1) return new BigInteger(); BigInteger result = new BigInteger(); result.words = new int[nwords]; return result; }
|
private static BigInteger alloc(int nwords) { if (nwords <= 1) return new BigInteger(); BigInteger result = new BigInteger(); result.words = new int[nwords]; return result; }
| 15,345
|
private static BigInteger and(BigInteger x, int y) { if (x.words == null) return BigInteger.make(x.ival & y); if (y >= 0) return BigInteger.make(x.words[0] & y); int len = x.ival; int[] words = new int[len]; words[0] = x.words[0] & y; while (--len > 0) words[len] = x.words[len]; return BigInteger.make(words, x.ival); }
|
private static BigInteger and(BigInteger x, int y) { if (x.words == null) return valueOf(x.ival & y); if (y >= 0) return BigInteger.make(x.words[0] & y); int len = x.ival; int[] words = new int[len]; words[0] = x.words[0] & y; while (--len > 0) words[len] = x.words[len]; return BigInteger.make(words, x.ival); }
| 15,347
|
private static BigInteger and(BigInteger x, int y) { if (x.words == null) return BigInteger.make(x.ival & y); if (y >= 0) return BigInteger.make(x.words[0] & y); int len = x.ival; int[] words = new int[len]; words[0] = x.words[0] & y; while (--len > 0) words[len] = x.words[len]; return BigInteger.make(words, x.ival); }
|
private static BigInteger and(BigInteger x, int y) { if (x.words == null) return BigInteger.make(x.ival & y); if (y >= 0) return valueOf(x.words[0] & y); int len = x.ival; int[] words = new int[len]; words[0] = x.words[0] & y; while (--len > 0) words[len] = x.words[len]; return BigInteger.make(words, x.ival); }
| 15,348
|
private static BigInteger and(BigInteger x, int y) { if (x.words == null) return BigInteger.make(x.ival & y); if (y >= 0) return BigInteger.make(x.words[0] & y); int len = x.ival; int[] words = new int[len]; words[0] = x.words[0] & y; while (--len > 0) words[len] = x.words[len]; return BigInteger.make(words, x.ival); }
|
private static BigInteger and(BigInteger x, int y) { if (x.words == null) return BigInteger.make(x.ival & y); if (y >= 0) return BigInteger.make(x.words[0] & y); int len = x.ival; int[] words = new int[len]; words[0] = x.words[0] & y; while (--len > 0) words[len] = x.words[len]; return make(words, x.ival); }
| 15,349
|
public int bitLength() { if (words == null) return MPN.intLength(ival); else return MPN.intLength(words, ival); }
|
public int bitLength() { if (words == null) return MPN.intLength(ival); return MPN.intLength(words, ival); }
| 15,350
|
private static BigInteger bitOp(int op, BigInteger x, BigInteger y) { switch (op) { case 0: return ZERO; case 1: return x.and(y); case 3: return x; case 5: return y; case 15: return make(-1); } BigInteger result = new BigInteger(); setBitOp(result, op, x, y); return result.canonicalize(); }
|
private static BigInteger bitOp(int op, BigInteger x, BigInteger y) { switch (op) { case 0: return ZERO; case 1: return x.and(y); case 3: return x; case 5: return y; case 15: return valueOf(-1); } BigInteger result = new BigInteger(); setBitOp(result, op, x, y); return result.canonicalize(); }
| 15,351
|
private static int[] byteArrayToIntArray(byte[] bytes, int sign) { // Determine number of words needed. int[] words = new int[bytes.length/4 + 1]; int nwords = words.length; // Create a int out of modulo 4 high order bytes. int bptr = 0; int word = sign; for (int i = bytes.length % 4; i > 0; --i, bptr++) word = (word << 8) | (((int) bytes[bptr]) & 0xff); words[--nwords] = word; // Elements remaining in byte[] are a multiple of 4. while (nwords > 0) words[--nwords] = bytes[bptr++] << 24 | (((int) bytes[bptr++]) & 0xff) << 16 | (((int) bytes[bptr++]) & 0xff) << 8 | (((int) bytes[bptr++]) & 0xff); return words; }
|
private static int[] byteArrayToIntArray(byte[] bytes, int sign) { // Determine number of words needed. int[] words = new int[bytes.length/4 + 1]; int nwords = words.length; // Create a int out of modulo 4 high order bytes. int bptr = 0; int word = sign; for (int i = bytes.length % 4; i > 0; --i, bptr++) word = (word << 8) | (bytes[bptr] & 0xff); words[--nwords] = word; // Elements remaining in byte[] are a multiple of 4. while (nwords > 0) words[--nwords] = bytes[bptr++] << 24 | (((int) bytes[bptr++]) & 0xff) << 16 | (((int) bytes[bptr++]) & 0xff) << 8 | (((int) bytes[bptr++]) & 0xff); return words; }
| 15,352
|
private static int[] byteArrayToIntArray(byte[] bytes, int sign) { // Determine number of words needed. int[] words = new int[bytes.length/4 + 1]; int nwords = words.length; // Create a int out of modulo 4 high order bytes. int bptr = 0; int word = sign; for (int i = bytes.length % 4; i > 0; --i, bptr++) word = (word << 8) | (((int) bytes[bptr]) & 0xff); words[--nwords] = word; // Elements remaining in byte[] are a multiple of 4. while (nwords > 0) words[--nwords] = bytes[bptr++] << 24 | (((int) bytes[bptr++]) & 0xff) << 16 | (((int) bytes[bptr++]) & 0xff) << 8 | (((int) bytes[bptr++]) & 0xff); return words; }
|
private static int[] byteArrayToIntArray(byte[] bytes, int sign) { // Determine number of words needed. int[] words = new int[bytes.length/4 + 1]; int nwords = words.length; // Create a int out of modulo 4 high order bytes. int bptr = 0; int word = sign; for (int i = bytes.length % 4; i > 0; --i, bptr++) word = (word << 8) | (((int) bytes[bptr]) & 0xff); words[--nwords] = word; // Elements remaining in byte[] are a multiple of 4. while (nwords > 0) words[--nwords] = bytes[bptr++] << 24 | (((int) bytes[bptr++]) & 0xff) << 16 | (((int) bytes[bptr++]) & 0xff) << 8 | (((int) bytes[bptr++]) & 0xff); return words; }
| 15,353
|
private BigInteger canonicalize() { if (words != null && (ival = BigInteger.wordsNeeded(words, ival)) <= 1) { if (ival == 1) ival = words[0]; words = null; } if (words == null && ival >= minFixNum && ival <= maxFixNum) return smallFixNums[(int) ival - minFixNum]; return this; }
|
private BigInteger canonicalize() { if (words != null && (ival = BigInteger.wordsNeeded(words, ival)) <= 1) { if (ival == 1) ival = words[0]; words = null; } if (words == null && ival >= minFixNum && ival <= maxFixNum) return smallFixNums[ival - minFixNum]; return this; }
| 15,354
|
private static void divide(long x, long y, BigInteger quotient, BigInteger remainder, int rounding_mode) { boolean xNegative, yNegative; if (x < 0) { xNegative = true; if (x == Long.MIN_VALUE) { divide(BigInteger.make(x), BigInteger.make(y), quotient, remainder, rounding_mode); return; } x = -x; } else xNegative = false; if (y < 0) { yNegative = true; if (y == Long.MIN_VALUE) { if (rounding_mode == TRUNCATE) { // x != Long.Min_VALUE implies abs(x) < abs(y) if (quotient != null) quotient.set(0); if (remainder != null) remainder.set(x); } else divide(BigInteger.make(x), BigInteger.make(y), quotient, remainder, rounding_mode); return; } y = -y; } else yNegative = false; long q = x / y; long r = x % y; boolean qNegative = xNegative ^ yNegative; boolean add_one = false; if (r != 0) { switch (rounding_mode) { case TRUNCATE: break; case CEILING: case FLOOR: if (qNegative == (rounding_mode == FLOOR)) add_one = true; break; case ROUND: add_one = r > ((y - (q & 1)) >> 1); break; } } if (quotient != null) { if (add_one) q++; if (qNegative) q = -q; quotient.set(q); } if (remainder != null) { // The remainder is by definition: X-Q*Y if (add_one) { // Subtract the remainder from Y. r = y - r; // In this case, abs(Q*Y) > abs(X). // So sign(remainder) = -sign(X). xNegative = ! xNegative; } else { // If !add_one, then: abs(Q*Y) <= abs(X). // So sign(remainder) = sign(X). } if (xNegative) r = -r; remainder.set(r); } }
|
private static void divide(long x, long y, BigInteger quotient, BigInteger remainder, int rounding_mode) { boolean xNegative, yNegative; if (x < 0) { xNegative = true; if (x == Long.MIN_VALUE) { divide(valueOf(x), valueOf(y), quotient, remainder, rounding_mode); return; } x = -x; } else xNegative = false; if (y < 0) { yNegative = true; if (y == Long.MIN_VALUE) { if (rounding_mode == TRUNCATE) { // x != Long.Min_VALUE implies abs(x) < abs(y) if (quotient != null) quotient.set(0); if (remainder != null) remainder.set(x); } else divide(valueOf(x), valueOf(y), quotient, remainder, rounding_mode); return; } y = -y; } else yNegative = false; long q = x / y; long r = x % y; boolean qNegative = xNegative ^ yNegative; boolean add_one = false; if (r != 0) { switch (rounding_mode) { case TRUNCATE: break; case CEILING: case FLOOR: if (qNegative == (rounding_mode == FLOOR)) add_one = true; break; case ROUND: add_one = r > ((y - (q & 1)) >> 1); break; } } if (quotient != null) { if (add_one) q++; if (qNegative) q = -q; quotient.set(q); } if (remainder != null) { // The remainder is by definition: X-Q*Y if (add_one) { // Subtract the remainder from Y. r = y - r; // In this case, abs(Q*Y) > abs(X). // So sign(remainder) = -sign(X). xNegative = ! xNegative; } else { // If !add_one, then: abs(Q*Y) <= abs(X). // So sign(remainder) = sign(X). } if (xNegative) r = -r; remainder.set(r); } }
| 15,355
|
public double doubleValue() { if (words == null) return (double) ival; if (ival <= 2) return (double) longValue(); if (isNegative()) return BigInteger.neg(this).roundToDouble(0, true, false); else return roundToDouble(0, false, false); }
|
public double doubleValue() { if (words == null) return (double) ival; if (ival <= 2) return (double) longValue(); if (isNegative()) return BigInteger.neg(this).roundToDouble(0, true, false); else return roundToDouble(0, false, false); }
| 15,356
|
private static final int[] euclidInv(int a, int b, int prevDiv) { // Storage for return values, plus one slot for a temp int (see below). int[] xy; if (b == 0) throw new ArithmeticException("not invertible"); else if (b == 1) { // Success: values are indeed invertible! // Bottom of the recursion reached; start unwinding. xy = new int[3]; xy[0] = -prevDiv; xy[1] = 1; return xy; } xy = euclidInv(b, a % b, a / b); // Recursion happens here. // xy[2] is just temp storage for intermediate results in the following // calculation. This saves us a bit of space over having an int // allocated at every level of this recursive method. xy[2] = xy[0]; xy[0] = xy[2] * -prevDiv + xy[1]; xy[1] = xy[2]; return xy; }
|
private static final int[] euclidInv(int a, int b, int prevDiv) { // Storage for return values, plus one slot for a temp int (see below). if (b == 0) throw new ArithmeticException("not invertible"); else if (b == 1) { // Success: values are indeed invertible! // Bottom of the recursion reached; start unwinding. xy = new int[3]; xy[0] = -prevDiv; xy[1] = 1; return xy; } xy = euclidInv(b, a % b, a / b); // Recursion happens here. // xy[2] is just temp storage for intermediate results in the following // calculation. This saves us a bit of space over having an int // allocated at every level of this recursive method. xy[2] = xy[0]; xy[0] = xy[2] * -prevDiv + xy[1]; xy[1] = xy[2]; return xy; }
| 15,357
|
private static final int[] euclidInv(int a, int b, int prevDiv) { // Storage for return values, plus one slot for a temp int (see below). int[] xy; if (b == 0) throw new ArithmeticException("not invertible"); else if (b == 1) { // Success: values are indeed invertible! // Bottom of the recursion reached; start unwinding. xy = new int[3]; xy[0] = -prevDiv; xy[1] = 1; return xy; } xy = euclidInv(b, a % b, a / b); // Recursion happens here. // xy[2] is just temp storage for intermediate results in the following // calculation. This saves us a bit of space over having an int // allocated at every level of this recursive method. xy[2] = xy[0]; xy[0] = xy[2] * -prevDiv + xy[1]; xy[1] = xy[2]; return xy; }
|
private static final int[] euclidInv(int a, int b, int prevDiv) { // Storage for return values, plus one slot for a temp int (see below). int[] xy; if (b == 0) throw new ArithmeticException("not invertible"); else if (b == 1) { // Success: values are indeed invertible! // Bottom of the recursion reached; start unwinding. xy = new int[3]; xy[0] = -prevDiv; xy[1] = 1; return xy; } xy = euclidInv(b, a % b, a / b); // Recursion happens here. // xy[2] is just temp storage for intermediate results in the following // calculation. This saves us a bit of space over having an int // allocated at every level of this recursive method. xy[2] = xy[0]; xy[0] = xy[2] * -prevDiv + xy[1]; xy[1] = xy[2]; return xy; }
| 15,358
|
private static final int[] euclidInv(int a, int b, int prevDiv) { // Storage for return values, plus one slot for a temp int (see below). int[] xy; if (b == 0) throw new ArithmeticException("not invertible"); else if (b == 1) { // Success: values are indeed invertible! // Bottom of the recursion reached; start unwinding. xy = new int[3]; xy[0] = -prevDiv; xy[1] = 1; return xy; } xy = euclidInv(b, a % b, a / b); // Recursion happens here. // xy[2] is just temp storage for intermediate results in the following // calculation. This saves us a bit of space over having an int // allocated at every level of this recursive method. xy[2] = xy[0]; xy[0] = xy[2] * -prevDiv + xy[1]; xy[1] = xy[2]; return xy; }
|
private static final int[] euclidInv(int a, int b, int prevDiv) { // Storage for return values, plus one slot for a temp int (see below). int[] xy; if (b == 0) throw new ArithmeticException("not invertible"); else if (b == 1) { // Success: values are indeed invertible! // Bottom of the recursion reached; start unwinding. xy = new int[3]; xy[0] = -prevDiv; xy[1] = 1; return xy; } xy = euclidInv(b, a % b, a / b); // Recursion happens here. // xy[2] is just temp storage for intermediate results in the following // calculation. This saves us a bit of space over having an int // allocated at every level of this recursive method. xy[2] = xy[0]; xy[0] = xy[2] * -prevDiv + xy[1]; xy[1] = xy[2]; return xy; }
| 15,359
|
private static final int[] euclidInv(int a, int b, int prevDiv) { // Storage for return values, plus one slot for a temp int (see below). int[] xy; if (b == 0) throw new ArithmeticException("not invertible"); else if (b == 1) { // Success: values are indeed invertible! // Bottom of the recursion reached; start unwinding. xy = new int[3]; xy[0] = -prevDiv; xy[1] = 1; return xy; } xy = euclidInv(b, a % b, a / b); // Recursion happens here. // xy[2] is just temp storage for intermediate results in the following // calculation. This saves us a bit of space over having an int // allocated at every level of this recursive method. xy[2] = xy[0]; xy[0] = xy[2] * -prevDiv + xy[1]; xy[1] = xy[2]; return xy; }
|
private static final int[] euclidInv(int a, int b, int prevDiv) { // Storage for return values, plus one slot for a temp int (see below). int[] xy; if (b == 0) throw new ArithmeticException("not invertible"); else if (b == 1) { // Success: values are indeed invertible! // Bottom of the recursion reached; start unwinding. xy = new int[3]; xy[0] = -prevDiv; xy[1] = 1; return xy; } xy = euclidInv(b, a % b, a / b); // Recursion happens here. // xy[2] is just temp storage for intermediate results in the following // calculation. This saves us a bit of space over having an int // allocated at every level of this recursive method. xy[2] = xy[0]; xy[0] = xy[2] * -prevDiv + xy[1]; xy[1] = xy[2]; return xy; }
| 15,360
|
private void format(int radix, StringBuffer buffer) { if (words == null) buffer.append(Integer.toString(ival, radix)); else if (ival <= 2) buffer.append(Long.toString(longValue(), radix)); else { boolean neg = isNegative(); int[] work; if (neg || radix != 16) { work = new int[ival]; getAbsolute(work); } else work = words; int len = ival; int buf_size = len * (MPN.chars_per_word(radix) + 1); if (radix == 16) { if (neg) buffer.append('-'); int buf_start = buffer.length(); for (int i = len; --i >= 0; ) { int word = work[i]; for (int j = 8; --j >= 0; ) { int hex_digit = (word >> (4 * j)) & 0xF; // Suppress leading zeros: if (hex_digit > 0 || buffer.length() > buf_start) buffer.append(Character.forDigit(hex_digit, 16)); } } } else { int i = buffer.length(); for (;;) { int digit = MPN.divmod_1(work, work, len, radix); buffer.append(Character.forDigit(digit, radix)); while (len > 0 && work[len-1] == 0) len--; if (len == 0) break; } if (neg) buffer.append('-'); /* Reverse buffer. */ int j = buffer.length() - 1; while (i < j) { char tmp = buffer.charAt(i); buffer.setCharAt(i, buffer.charAt(j)); buffer.setCharAt(j, tmp); i++; j--; } } } }
|
private void format(int radix, StringBuffer buffer) { if (words == null) buffer.append(Integer.toString(ival, radix)); else if (ival <= 2) buffer.append(Long.toString(longValue(), radix)); else { boolean neg = isNegative(); int[] work; if (neg || radix != 16) { work = new int[ival]; getAbsolute(work); } else work = words; int len = ival; if (radix == 16) { if (neg) buffer.append('-'); int buf_start = buffer.length(); for (int i = len; --i >= 0; ) { int word = work[i]; for (int j = 8; --j >= 0; ) { int hex_digit = (word >> (4 * j)) & 0xF; // Suppress leading zeros: if (hex_digit > 0 || buffer.length() > buf_start) buffer.append(Character.forDigit(hex_digit, 16)); } } } else { int i = buffer.length(); for (;;) { int digit = MPN.divmod_1(work, work, len, radix); buffer.append(Character.forDigit(digit, radix)); while (len > 0 && work[len-1] == 0) len--; if (len == 0) break; } if (neg) buffer.append('-'); /* Reverse buffer. */ int j = buffer.length() - 1; while (i < j) { char tmp = buffer.charAt(i); buffer.setCharAt(i, buffer.charAt(j)); buffer.setCharAt(j, tmp); i++; j--; } } } }
| 15,361
|
private static final int gcd(int a, int b) { // Euclid's algorithm, copied from libg++. if (b > a) { int tmp = a; a = b; b = tmp; } for(;;) { if (b == 0) return a; else if (b == 1) return b; else { int tmp = b; b = a % b; a = tmp; } } }
|
private static final int gcd(int a, int b) { // Euclid's algorithm, copied from libg++. if (b > a) { tmp = a; a = b; b = tmp; } for(;;) { if (b == 0) return a; else if (b == 1) return b; else { int tmp = b; b = a % b; a = tmp; } } }
| 15,362
|
private static final int gcd(int a, int b) { // Euclid's algorithm, copied from libg++. if (b > a) { int tmp = a; a = b; b = tmp; } for(;;) { if (b == 0) return a; else if (b == 1) return b; else { int tmp = b; b = a % b; a = tmp; } } }
|
private static final int gcd(int a, int b) { // Euclid's algorithm, copied from libg++. if (b > a) { int tmp = a; a = b; b = tmp; } for(;;) { if (b == 0) return a; if (b == 1) return b; else { int tmp = b; b = a % b; a = tmp; } } }
| 15,363
|
private static final int gcd(int a, int b) { // Euclid's algorithm, copied from libg++. if (b > a) { int tmp = a; a = b; b = tmp; } for(;;) { if (b == 0) return a; else if (b == 1) return b; else { int tmp = b; b = a % b; a = tmp; } } }
|
private static final int gcd(int a, int b) { // Euclid's algorithm, copied from libg++. if (b > a) { int tmp = a; a = b; b = tmp; } for(;;) { if (b == 0) return a; else if (b == 1) return b; else { int tmp = b; b = a % b; a = tmp; } } }
| 15,364
|
private static final int gcd(int a, int b) { // Euclid's algorithm, copied from libg++. if (b > a) { int tmp = a; a = b; b = tmp; } for(;;) { if (b == 0) return a; else if (b == 1) return b; else { int tmp = b; b = a % b; a = tmp; } } }
|
private static final int gcd(int a, int b) { // Euclid's algorithm, copied from libg++. if (b > a) { int tmp = a; a = b; b = tmp; for(;;) { if (b == 0) return a; else if (b == 1) return b; else { int tmp = b; b = a % b; a = tmp;
| 15,365
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. BigInteger rem = new BigInteger(); int i; for (i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
| 15,366
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; divide(this, smallFixNums[primes[i] - minFixNum], null, rem, TRUNCATE); if (rem.canonicalize().isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
| 15,367
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(valueOf(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
| 15,368
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
| 15,369
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
| 15,370
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
| 15,371
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(make(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
|
public boolean isProbablePrime(int certainty) { /** We'll use the Rabin-Miller algorithm for doing a probabilistic * primality test. It is fast, easy and has faster decreasing odds of a * composite passing than with other tests. This means that this * method will actually have a probability much greater than the * 1 - .5^certainty specified in the JCL (p. 117), but I don't think * anyone will complain about better performance with greater certainty. * * The Rabin-Miller algorithm can be found on pp. 259-261 of "Applied * Cryptography, Second Edition" by Bruce Schneier. */ // First rule out small prime factors and assure the number is odd. for (int i = 0; i < primes.length; i++) { if (words == null && ival == primes[i]) return true; if (remainder(make(primes[i])).isZero()) return false; } // Now perform the Rabin-Miller test. // NB: I know that this can be simplified programatically, but // I have tried to keep it as close as possible to the algorithm // as written in the Schneier book for reference purposes. // Set b to the number of times 2 evenly divides (this - 1). // I.e. 2^b is the largest power of 2 that divides (this - 1). BigInteger pMinus1 = add(this, -1); int b = pMinus1.getLowestSetBit(); // Set m such that this = 1 + 2^b * m. BigInteger m = pMinus1.divide(make(2L << b - 1)); Random rand = new Random(); while (certainty-- > 0) { // Pick a random number greater than 1 and less than this. // The algorithm says to pick a small number to make the calculations // go faster, but it doesn't say how small; we'll use 2 to 1024. int a = rand.nextInt(); a = (a < 0 ? -a : a) % 1023 + 2; BigInteger z = make(a).modPow(m, this); if (z.isOne() || z.equals(pMinus1)) continue; // Passes the test; may be prime. int i; for (i = 0; i < b; ) { if (z.isOne()) return false; i++; if (z.equals(pMinus1)) break; // Passes the test; may be prime. z = z.modPow(valueOf(2), this); } if (i == b && !z.equals(pMinus1)) return false; } return true; }
| 15,372
|
private static BigInteger make(long value) { if (value >= minFixNum && value <= maxFixNum) return smallFixNums[(int)value - minFixNum]; int i = (int) value; if ((long)i == value) return new BigInteger(i); BigInteger result = alloc(2); result.ival = 2; result.words[0] = i; result.words[1] = (int) (value >> 32); return result; }
|
private static BigInteger make(int[] words, int len) { if (value >= minFixNum && value <= maxFixNum) return smallFixNums[(int)value - minFixNum]; int i = (int) value; if ((long)i == value) return new BigInteger(i); BigInteger result = alloc(2); result.ival = 2; result.words[0] = i; result.words[1] = (int) (value >> 32); return result; }
| 15,373
|
private static BigInteger make(long value) { if (value >= minFixNum && value <= maxFixNum) return smallFixNums[(int)value - minFixNum]; int i = (int) value; if ((long)i == value) return new BigInteger(i); BigInteger result = alloc(2); result.ival = 2; result.words[0] = i; result.words[1] = (int) (value >> 32); return result; }
|
private static BigInteger make(long value) { if (value >= minFixNum && value <= maxFixNum) return smallFixNums[(int)value - minFixNum]; int i = (int) value; if ((long)i == value) return new BigInteger(i); BigInteger result = alloc(2); result.ival = 2; result.words[0] = i; result.words[1] = (int) (value >> 32); return result; }
| 15,374
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
| 15,375
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
| 15,376
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
| 15,377
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
| 15,378
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
| 15,379
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { result = x; x = y; y = result; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
| 15,380
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); result = euclidInv(y, rem, quot)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
|
public BigInteger modInverse(BigInteger y) { if (y.isNegative() || y.isZero()) throw new ArithmeticException("non-positive modulo"); // Degenerate cases. if (y.isOne()) return ZERO; else if (isOne()) return ONE; // Use Euclid's algorithm as in gcd() but do this recursively // rather than in a loop so we can use the intermediate results as we // unwind from the recursion. // Used http://www.math.nmsu.edu/~crypto/EuclideanAlgo.html as reference. BigInteger result = new BigInteger(); int xval = ival; int yval = y.ival; boolean swapped = false; if (y.words == null) { // The result is guaranteed to be less than the modulus, y (which is // an int), so simplify this by working with the int result of this // modulo y. Also, if this is negative, make it positive via modulo // math. Note that BigInteger.mod() must be used even if this is // already an int as the % operator would provide a negative result if // this is negative, BigInteger.mod() never returns negative values. if (words != null || isNegative()) xval = mod(y).ival; // Swap values so x > y. if (yval > xval) { int tmp = xval; xval = yval; yval = tmp; swapped = true; } // Normally, the result is in the 2nd element of the array, but // if originally x < y, then x and y were swapped and the result // is in the 1st element of the array. result.ival = euclidInv(yval, xval % yval, xval / yval)[swapped ? 0 : 1]; // Result can't be negative, so make it positive by adding the // original modulus, y.ival (not the possibly "swapped" yval). if (result.ival < 0) result.ival += y.ival; } else { BigInteger x = this; // As above, force this to be a positive value via modulo math. if (isNegative()) x = mod(y); // Swap values so x > y. if (x.compareTo(y) < 0) { BigInteger tmp = x; x = y; y = tmp; swapped = true; } // As above (for ints), result will be in the 2nd element unless // the original x and y were swapped. BigInteger rem = new BigInteger(); BigInteger quot = new BigInteger(); divide(x, y, quot, rem, FLOOR); // quot and rem may not be in canonical form. ensure rem.canonicalize(); quot.canonicalize(); BigInteger[] xy = new BigInteger[2]; euclidInv(y, rem, quot, xy); result = swapped ? xy[0] : xy[1]; // Result can't be negative, so make it positive by adding the // original modulus, y (which is now x if they were swapped). if (result.isNegative()) result = add(result, swapped ? x : y, 1); } return result; }
| 15,381
|
public BigInteger modPow(BigInteger exponent, BigInteger m) { if (m.isNegative() || m.isZero()) throw new ArithmeticException("non-positive modulo"); if (exponent.isNegative()) return modInverse(m); if (exponent.isOne()) return mod(m); // To do this naively by first raising this to the power of exponent // and then performing modulo m would be extremely expensive, especially // for very large numbers. The solution is found in Number Theory // where a combination of partial powers and modulos can be done easily. // // We'll use the algorithm for Additive Chaining which can be found on // p. 244 of "Applied Cryptography, Second Edition" by Bruce Schneier. BigInteger s, t, u; int i; s = ONE; t = this; u = exponent; while (!u.isZero()) { if (u.and(ONE).isOne()) s = times(s, t).mod(m); u = u.shiftRight(1); t = times(t, t).mod(m); } return s; }
|
public BigInteger modPow(BigInteger exponent, BigInteger m) { if (m.isNegative() || m.isZero()) throw new ArithmeticException("non-positive modulo"); if (exponent.isNegative()) return modInverse(m); if (exponent.isOne()) return mod(m); // To do this naively by first raising this to the power of exponent // and then performing modulo m would be extremely expensive, especially // for very large numbers. The solution is found in Number Theory // where a combination of partial powers and modulos can be done easily. // // We'll use the algorithm for Additive Chaining which can be found on // p. 244 of "Applied Cryptography, Second Edition" by Bruce Schneier. BigInteger s, t, u; int i; s = ONE; t = this; u = exponent; while (!u.isZero()) { if (u.and(ONE).isOne()) s = times(s, t).mod(m); u = u.shiftRight(1); t = times(t, t).mod(m); } return s; }
| 15,382
|
private static BigInteger neg(BigInteger x) { if (x.words == null && x.ival != Integer.MIN_VALUE) return make(- x.ival); BigInteger result = new BigInteger(0); result.setNegative(x); return result.canonicalize(); }
|
private static BigInteger neg(BigInteger x) { if (x.words == null && x.ival != Integer.MIN_VALUE) return valueOf(- x.ival); BigInteger result = new BigInteger(0); result.setNegative(x); return result.canonicalize(); }
| 15,383
|
public BigInteger pow(int exponent) { if (exponent <= 0) { if (exponent == 0) return ONE; else throw new ArithmeticException("negative exponent"); } if (isZero()) return this; int plen = words == null ? 1 : ival; // Length of pow2. int blen = ((bitLength() * exponent) >> 5) + 2 * plen; boolean negative = isNegative() && (exponent & 1) != 0; int[] pow2 = new int [blen]; int[] rwords = new int [blen]; int[] work = new int [blen]; getAbsolute(pow2); // pow2 = abs(this); int rlen = 1; rwords[0] = 1; // rwords = 1; for (;;) // for (i = 0; ; i++) { // pow2 == this**(2**i) // prod = this**(sum(j=0..i-1, (exponent>>j)&1)) if ((exponent & 1) != 0) { // r *= pow2 MPN.mul(work, pow2, plen, rwords, rlen); int[] temp = work; work = rwords; rwords = temp; rlen += plen; while (rwords[rlen - 1] == 0) rlen--; } exponent >>= 1; if (exponent == 0) break; // pow2 *= pow2; MPN.mul(work, pow2, plen, pow2, plen); int[] temp = work; work = pow2; pow2 = temp; // swap to avoid a copy plen *= 2; while (pow2[plen - 1] == 0) plen--; } if (rwords[rlen - 1] < 0) rlen++; if (negative) negate(rwords, rwords, rlen); return BigInteger.make(rwords, rlen); }
|
public BigInteger pow(int exponent) { if (exponent <= 0) { if (exponent == 0) return ONE; throw new ArithmeticException("negative exponent"); } if (isZero()) return this; int plen = words == null ? 1 : ival; // Length of pow2. int blen = ((bitLength() * exponent) >> 5) + 2 * plen; boolean negative = isNegative() && (exponent & 1) != 0; int[] pow2 = new int [blen]; int[] rwords = new int [blen]; int[] work = new int [blen]; getAbsolute(pow2); // pow2 = abs(this); int rlen = 1; rwords[0] = 1; // rwords = 1; for (;;) // for (i = 0; ; i++) { // pow2 == this**(2**i) // prod = this**(sum(j=0..i-1, (exponent>>j)&1)) if ((exponent & 1) != 0) { // r *= pow2 MPN.mul(work, pow2, plen, rwords, rlen); int[] temp = work; work = rwords; rwords = temp; rlen += plen; while (rwords[rlen - 1] == 0) rlen--; } exponent >>= 1; if (exponent == 0) break; // pow2 *= pow2; MPN.mul(work, pow2, plen, pow2, plen); int[] temp = work; work = pow2; pow2 = temp; // swap to avoid a copy plen *= 2; while (pow2[plen - 1] == 0) plen--; } if (rwords[rlen - 1] < 0) rlen++; if (negative) negate(rwords, rwords, rlen); return BigInteger.make(rwords, rlen); }
| 15,384
|
private void setNegative(BigInteger x) { int len = x.ival; if (x.words == null) { if (len == Integer.MIN_VALUE) set(- (long) len); else set(-len); return; } realloc(len + 1); if (BigInteger.negate(words, x.words, len)) words[len++] = 0; ival = len; }
|
private void setNegative(BigInteger x) { int len = x.ival; if (x.words == null) { if (len == Integer.MIN_VALUE) set(- (long) len); else set(-len); return; } realloc(len + 1); if (negate(words, x.words, len)) words[len++] = 0; ival = len; }
| 15,385
|
private static BigInteger shift(BigInteger x, int count) { if (x.words == null) { if (count <= 0) return make(count > -32 ? x.ival >> (-count) : x.ival < 0 ? -1 : 0); if (count < 32) return make((long) x.ival << count); } if (count == 0) return x; BigInteger result = new BigInteger(0); result.setShift(x, count); return result.canonicalize(); }
|
private static BigInteger shift(BigInteger x, int count) { if (x.words == null) { if (count <= 0) return valueOf(count > -32 ? x.ival >> (-count) : x.ival < 0 ? -1 : 0); if (count < 32) return make((long) x.ival << count); } if (count == 0) return x; BigInteger result = new BigInteger(0); result.setShift(x, count); return result.canonicalize(); }
| 15,386
|
private static BigInteger shift(BigInteger x, int count) { if (x.words == null) { if (count <= 0) return make(count > -32 ? x.ival >> (-count) : x.ival < 0 ? -1 : 0); if (count < 32) return make((long) x.ival << count); } if (count == 0) return x; BigInteger result = new BigInteger(0); result.setShift(x, count); return result.canonicalize(); }
|
private static BigInteger shift(BigInteger x, int count) { if (x.words == null) { if (count <= 0) return make(count > -32 ? x.ival >> (-count) : x.ival < 0 ? -1 : 0); if (count < 32) return valueOf((long) x.ival << count); } if (count == 0) return x; BigInteger result = new BigInteger(0); result.setShift(x, count); return result.canonicalize(); }
| 15,387
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.