📄 cmshtmlconverterconfig.java
字号:
*
* @return ArrayList with CmsHtmlConverterObjectReplaceBlocks
*/
protected ArrayList getReplaceBlocks() {
return m_replaceBlocks;
}
/**
* Returns boolean if output is in XHTML format.<p>
*
* @return true, if output has to be XHTML, otherwise false
*/
protected boolean getXhtmlOutput() {
return m_xhtmlOutput;
}
/**
* Returns global prefix defined in configuration.<p>
*
* @return String with global prefix
*/
protected String getGlobalPrefix() {
return m_globalPrefix;
}
/**
* Returns global suffix defined in configuration.<p>
*
* @return String with global suffix
*/
protected String getGlobalSuffix() {
return m_globalSuffix;
}
/**
* Returns boolean if global prefix and suffix have to be added to every new line.<p>
*
* @return true, if prefix and suffix are added in every new line, otherwise false
*/
protected boolean getGlobalAddEveryLine() {
return m_globalAddEveryLine;
}
/**
* Returns boolean if encoded brackets are used.<p>
*
* @return true, when encoded brackets are defined, otherwise false
*/
protected boolean getUseBrackets() {
return m_useBrackets;
}
/**
* Returns boolean if quotationmarks must be encoded.<p>
*
* @return true, when quotationmarks must be encoded
*/
protected boolean getEncodeQuotationmarks() {
return m_encodeQuotationmarks;
}
/**
* Returns the String for quotationmarks.<p>
*
* @return String with value for quotationmarks
*/
protected String getQuotationmark() {
return m_quotationmark;
}
/**
* Adds new object to ArrayList m_replaceTags.<p>
*
* @param prefix prefix String
* @param tagName tagname String
* @param attributeName attributeName String
* @param attributeValue attributeNalue String
* @param replaceStartTag replaceStartTag String
* @param replaceEndTag replaceEndTag String
* @param suffix suffix String
* @param getReplaceFromAttrs getReplaceFromAttrs boolean
* @param startAttribute startAttribute String
* @param endAttribute endAttribute String
* @param parameter parameter String
* @param replaceParamAttr flag to indicate the parameter replacement
* @return true if object was successfully added, otherwise false
*/
protected boolean addObjectReplaceTag(String prefix, String tagName,
String attributeName, String attributeValue, String replaceStartTag,
String replaceEndTag, String suffix, boolean getReplaceFromAttrs,
String startAttribute, String endAttribute, String parameter, boolean replaceParamAttr) {
return m_replaceTags.add(
new CmsHtmlConverterObjectReplaceTags(
prefix,
tagName,
attributeName,
attributeValue,
replaceStartTag,
replaceEndTag,
suffix,
getReplaceFromAttrs,
startAttribute,
endAttribute,
parameter,
replaceParamAttr));
}
/**
* Removes object from position index from ArrayList m_replaceTags.<p>
*
* @param index index of removed object
*/
protected void removeObjectReplaceTag(int index) {
m_replaceTags.remove(index);
}
/**
* Adds new object to ArrayList m_replaceBlocks.<p>
*
* @param prefix prefix String
* @param tagName tagname String
* @param attributeName attributeName String
* @param attributeValue attributeNalue String
* @param replaceString replaceString String
* @param suffix suffix String
* @param getReplaceFromAttrs getReplaceFromAttrs boolean
* @param replaceAttribute replaceAttribute String
* @param parameter parameter String
* @return true if object was successfully added, otherwise false
*/
protected boolean addObjectReplaceBlock(String prefix, String tagName,
String attributeName, String attributeValue, String replaceString,
String suffix, boolean getReplaceFromAttrs, String replaceAttribute, String parameter) {
return m_replaceBlocks.add(
new CmsHtmlConverterObjectReplaceBlocks(
prefix,
tagName,
attributeName,
attributeValue,
replaceString,
suffix,
getReplaceFromAttrs,
replaceAttribute,
parameter));
}
/**
* Removes object from position index from ArrayList m_replaceBlocks.<p>
*
* @param index index of removed object
*/
protected void removeObjectReplaceBlock(int index) {
m_replaceBlocks.remove(index);
}
/**
* Scans a String for coded bracket subStrings and replaces them.<p>
*
* @param content String to scan
* @return String with real "<" and ">"
*/
protected String scanBrackets(String content) {
content = m_tools.replaceString(content, m_openBracket, "<");
content = m_tools.replaceString(content, m_closeBracket, ">");
return content;
}
/**
* Initialises configuration from String.<p>
*
* @param confString String with XML configuration
*/
protected void init(String confString) {
InputStream in = new ByteArrayInputStream(confString.getBytes());
init(in);
}
/**
* Initialises configuration from InputStream.<p>
*
* @param in InputStream with XML configuration
*/
protected void init(InputStream in) {
Node node;
Tidy tidy = new Tidy();
/* initialise Tidy */
tidy.setXmlTags(true);
tidy.setQuiet(true);
tidy.setOnlyErrors(true);
tidy.setShowWarnings(false);
/* if converter was configured, clear previous configuration */
if (m_isConfigured) {
clearConfiguration();
}
node = tidy.parseDOM(in, null);
parseConfig(node);
buildObjects();
m_isConfigured = true;
}
/**
* Clears all variables and objects if the configuration is redefined.<p>
*/
private void clearConfiguration() {
m_globalAddEveryLine = false;
m_useBrackets = false;
m_globalPrefix = "";
m_globalSuffix = "";
m_openBracket = "";
m_closeBracket = "";
m_encodeQuotationmarks = false;
m_quotationmark = "";
m_replaceTagsPrefix = "";
m_replaceTagsSuffix = "";
m_replaceTagsAddEveryLine = false;
m_replaceTagsUseDefaults = false;
m_replaceBlocksPrefix = "";
m_replaceBlocksSuffix = "";
m_replaceBlocksAddEveryLine = false;
m_replaceBlocksUseDefaults = false;
m_replaceStringsPrefix = "";
m_replaceStringsSuffix = "";
m_replaceStringsAddEveryLine = false;
m_replaceStringsUseDefaults = false;
m_tempReplaceContent.clear();
m_tempReplaceStrings.clear();
m_tempReplaceTags.clear();
m_tempReplaceBlocks.clear();
m_replaceContent.clear();
m_removeTags.clear();
m_removeBlocks.clear();
m_inlineTags.clear();
m_replaceExtendedChars.clear();
m_replaceStrings.clear();
m_replaceTags.clear();
m_replaceBlocks.clear();
m_isConfigured = false;
}
/**
* Builds all objects after XML configuration was parsed.<p>
*/
private void buildObjects() {
boolean added = true;
/* scan global prefix and suffix for brackets */
if (m_useBrackets) {
m_globalPrefix = scanBrackets(m_globalPrefix);
m_globalSuffix = scanBrackets(m_globalSuffix);
}
/* set normal quotationmarks, if no encoding is required */
if (!m_encodeQuotationmarks) {
m_quotationmark = "\"";
}
/* builds ArrayList m_replaceContent */
buildObjectReplaceContent();
/* builds ArrayList m_replaceTags */
buildObjectReplaceTags();
/* builds ArrayList m_replaceBlocks */
buildObjectReplaceBlocks();
/* builds ArrayList m_replaceStrings */
buildObjectReplaceStrings();
/* build ArrayList m_extendedChars */
// Encoding project:
// String Chars = "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -