⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadvariable.java

📁 数据仓库工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        if (bJDBC) {
                            // going throw vector
                            for (int k = 0; k < this.vecReplaceInJDBC.size(); k++) {
                                // if this is to change
                                if (this.vecReplaceInJDBC.get(k).toString().equalsIgnoreCase("true")) {
                                    String sPreNameSu = this.vecVariablePrefix.get(k).toString()
                                            + this.vecVariableName.get(k).toString()
                                            + this.vecVariableSufix.get(k).toString();
                                    // if costant is variable
//                                    if (value.equalsIgnoreCase(sPreNameSu)) {
//                                        value = this.vecVariableValue.get(k).toString();
//                                    }
											value = Utils.replaceAll(value, sPreNameSu, this.vecVariableValue.get(k).toString());
                                }
                            }
                        }
                    }
                    // + 4 allows space for one entitiy reference.
                    // If there's more than that, then the StringBuffer
                    // will automatically expand
                    // Need to use character references if the encoding
                    // can't support the character
                    StringBuffer encodedValue = new StringBuffer(value.length()
                            + 4);
                    for (int j = 0; j < value.length(); j++) {
                        char c = value.charAt(j);
                        if (c == '&')
                            encodedValue.append("&amp;");
                        else if (c == '<')
                            encodedValue.append("&lt;");
                        else if (c == '>')
                            encodedValue.append("&gt;");
                        else if (c == '\'')
                            encodedValue.append("&apos;");
                        else
                            encodedValue.append(c);
                    }
                    out.write(encodedValue.toString());
                    out.write("'");
                }
                out.write(">");
            }
            else if (name.equalsIgnoreCase("importDefinition")) {
                out.write("<" + name);
                for (int i = 0; i < atts.getLength(); i++) {
                    out.write(" ");
                    out.write(atts.getName(i));
                    out.write("='");
                    String value = atts.getValue(i);
                    if (atts.getName(i).equalsIgnoreCase("selectStatement")) {
                        // checking, and if Variable exists changing
                        if (bSQL) {
                            // going throw vector
                            for (int k = 0; k < this.vecReplaceInSQL.size(); k++) {
                                // if this is to change
                                if (this.vecReplaceInSQL.get(k).toString().equalsIgnoreCase("true")) {
                                    String sPreNameSu = this.vecVariablePrefix.get(k).toString()
                                            + this.vecVariableName.get(k).toString()
                                            + this.vecVariableSufix.get(k).toString();
                                    // if costant is variable
//                                    if (value.equalsIgnoreCase(sPreNameSu)) {
//                                        value = this.vecVariableValue.get(k).toString();
//                                    }
									 			value = Utils.replaceAll(value, sPreNameSu, this.vecVariableValue.get(k).toString());
                                }
                            }
                        }
                    }
                    // + 4 allows space for one entitiy reference.
                    // If there's more than that, then the StringBuffer
                    // will automatically expand
                    // Need to use character references if the encoding
                    // can't support the character
                    StringBuffer encodedValue = new StringBuffer(value.length()
                            + 4);                           
                    for (int j = 0; j < value.length(); j++) {
                        char c = value.charAt(j);
                        if (c == '&')
                            encodedValue.append("&amp;");
                        else if (c == '<')
                            encodedValue.append("&lt;");
                        else if (c == '>')
                            encodedValue.append("&gt;");
                        else if (c == '\'')
                            encodedValue.append("&apos;");
                        else
                            encodedValue.append(c);
                    }
                    out.write(encodedValue.toString());
                    out.write("'");
                }
                out.write(">");
            }

            else {
                out.write("<" + name);
                for (int i = 0; i < atts.getLength(); i++) {
                    out.write(" ");
                    out.write(atts.getName(i));
                    out.write("='");
                    String value = atts.getValue(i);
                    // + 4 allows space for one entitiy reference.
                    // If there's more than that, then the StringBuffer
                    // will automatically expand
                    // Need to use character references if the encoding
                    // can't support the character
                    StringBuffer encodedValue = new StringBuffer(value.length()
                            + 4);
                    for (int j = 0; j < value.length(); j++) {
                        char c = value.charAt(j);
                        if (c == '&')
                            encodedValue.append("&amp;");
                        else if (c == '<')
                            encodedValue.append("&lt;");
                        else if (c == '>')
                            encodedValue.append("&gt;");
                        else if (c == '\'')
                            encodedValue.append("&apos;");
                        else
                            encodedValue.append(c);
                    }
                    out.write(encodedValue.toString());
                    out.write("'");
                }
                out.write(">");
            }

            } catch (IOException e) {
             System.err.println(e);

        }
    }

    /** Characters.
     * @param ch is character array
     * @param start is int
     * @param length is length
     * @throws SAXException
     */
    public void characters (char ch[], int start, int length) throws SAXException {
        try {
            String s = new String(ch, start, length);            
            if (this.bSQL) {
                // going throw vector
                for (int k = 0; k < this.vecReplaceInJDBC.size(); k++) {
                    // if this is to change
                    if (this.vecReplaceInSQL.get(k).toString().equalsIgnoreCase("true")) {
                        String sPreNameSu = this.vecVariablePrefix.get(k).toString()
                                + this.vecVariableName.get(k).toString() +
                                this.vecVariableSufix.get(k).toString();
                        int j = s.indexOf(sPreNameSu);
                        // if costant is variable
                        while (j != -1) {
                            s = s.substring(0, j) + this.vecVariableValue.get(k).toString()
                                    + s.substring(j + sPreNameSu.length(),
                                    s.length());
                            j = s.indexOf(sPreNameSu);
                        }
                    }
                }
            }
//			+ 4 allows space for one entitiy reference.
			 // If there's more than that, then the StringBuffer
			 // will automatically expand
			 // Need to use character references if the encoding
			 // can't support the character
			 StringBuffer encodedValue = new StringBuffer(s.length()
					 + 4);
			 for (int j = 0; j < s.length(); j++) {
				 char c = s.charAt(j);
				 if (c == '&')
					 encodedValue.append("&amp;");
				 else if (c == '<')
					 encodedValue.append("&lt;");
				 else if (c == '>')
					 encodedValue.append("&gt;");
				 else if (c == '\'')
					 encodedValue.append("&apos;");
				 else
					 encodedValue.append(c);
			 }
			 out.write(encodedValue.toString());
			 
        } catch (Exception e) {
            System.err.println(e);
        }
    }

    /** Ignorable whitespace.
     * @param ch is character array
     * @param start is int
     * @param length is length
     * @throws SAXException
     */
    public void ignorableWhitespace (char ch[], int start, int length) {
        try {
            this.characters(ch, start, length);
        } catch (SAXException e) {
            System.err.println(e);
        }
    }

    /** End element.
     * @param name is name of the tag
     */
    public void endElement (String name) {
        if (!name.equalsIgnoreCase("include") && !name.equalsIgnoreCase("definitionInclude")) {
            try {
                out.write("</");
                out.write(name);
                out.write(">");
            } catch (IOException e) {
                System.err.println(e);
            }
        }
    }

    /** End document. */
    public void endDocument () {
        try {
            out.flush();
        } catch (IOException e) {
            System.err.println(e);
        }
    }

    //
    // ErrorHandler methods
    //
    /** Warning.
     * @param ex is SAXParseException object
     */
    public void warning (SAXParseException ex) {
        System.err.println("[Warning] " + getLocationString(ex) + ": " + ex.getMessage());
    }

    /** Error.
     * @param ex is SAXParseException object
     */
    public void error (SAXParseException ex) {
        System.err.println("[Error] " + getLocationString(ex) + ": " + ex.getMessage());
    }

    /** Fatal error.
     * @param ex is SAXParseException object
     * @throws SAXException
     */
    public void fatalError (SAXParseException ex) throws SAXException {
        System.err.println("[Fatal Error] " + getLocationString(ex) + ": " +
                ex.getMessage());
        throw  ex;
    }

    /** Returns a string of the location.
     * @param ex is SAXParseException object
     * @return string
     */
    private String getLocationString (SAXParseException ex) {
        StringBuffer str = new StringBuffer();
        String systemId = ex.getSystemId();
        if (systemId != null) {
            int index = systemId.lastIndexOf('/');
            if (index != -1)
                systemId = systemId.substring(index + 1);
            str.append(systemId);
        }
        str.append(':');
        str.append(ex.getLineNumber());
        str.append(':');
        str.append(ex.getColumnNumber());
        return  str.toString();
    }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -