📄 genericelement.java
字号:
this.begin_end_modifier = modifier;
setBeginEndModifierDefined(true);
return(this);
}
/**
Set the element modifier the default is no modifier.
@param modifier the modifier for the element a ? would result <br>
in <? ?>
*/
public Element setBeginModifier(char start_modifier,char end_modifier)
{
this.begin_start_modifier = start_modifier;
this.begin_end_modifier = end_modifier;
setBeginStartModifierDefined(true);
setBeginEndModifierDefined(true);
return(this);
}
/**
What is the element modifier for this tag.
*/
public char getBeginStartModifier()
{
return(begin_start_modifier);
}
/**
What is the element modifier for this tag.
*/
public char getBeginEndModifier()
{
return(begin_end_modifier);
}
/**
Remove the element modifier for this tag.
*/
public Element removeBeginStartModifier()
{
setBeginStartModifierDefined(false);
return(this);
}
/**
Remove the element modifier for this tag.
*/
public Element removeBeginEndModifier()
{
setBeginEndModifierDefined(false);
return(this);
}
/**
Modifier optimization
*/
private void setBeginStartModifierDefined(boolean val)
{
this.begin_start_modifier_defined = val;
}
/**
Modifier optimization
*/
private void setBeginEndModifierDefined(boolean val)
{
this.begin_end_modifier_defined = val;
}
/**
Modifier optimization
*/
protected boolean getEndStartModifierDefined()
{
return this.end_start_modifier_defined;
}
/**
Modifier optimization
*/
protected boolean getEndEndModifierDefined()
{
return this.end_end_modifier_defined;
}
/**
Set the element modifier the default is no modifier.
@param modifier the modifier for the element a ? would result <br>
in <? ?>
*/
public Element setEndModifier(char modifier)
{
setEndStartModifier(modifier);
setEndEndModifier(modifier);
setEndStartModifierDefined(true);
setEndEndModifierDefined(true);
return(this);
}
/**
Set the element modifier the default is no modifier.
@param modifier the modifier for the element a ? would result <br>
in <? >
*/
public Element setEndStartModifier(char modifier)
{
this.end_start_modifier = modifier;
setEndStartModifierDefined(true);
return(this);
}
/**
Set the element modifier the default is no modifier.
@param modifier the modifier for the element a ? would result <br>
in < ?>
*/
public Element setEndEndModifier(char modifier)
{
this.end_end_modifier = modifier;
setEndEndModifierDefined(true);
return(this);
}
/**
Set the element modifier the default is no modifier.
@param modifier the modifier for the element a ? would result <br>
in <? ?>
*/
public Element setEndModifier(char start_modifier,char end_modifier)
{
this.end_start_modifier = start_modifier;
this.end_end_modifier = end_modifier;
setEndStartModifierDefined(true);
setEndEndModifierDefined(true);
return(this);
}
/**
What is the element modifier for this tag.
*/
public char getEndStartModifier()
{
return(end_start_modifier);
}
/**
What is the element modifier for this tag.
*/
public char getEndEndModifier()
{
return(end_end_modifier);
}
/**
Remove the element modifier for this tag.
*/
public Element removeEndStartModifier()
{
setEndStartModifierDefined(false);
return(this);
}
/**
Remove the element modifier for this tag.
*/
public Element removeEndEndModifier()
{
setEndEndModifierDefined(false);
return(this);
}
/**
Modifier optimization
*/
private void setEndStartModifierDefined(boolean val)
{
this.end_start_modifier_defined = val;
}
/**
Modifier optimization
*/
private void setEndEndModifierDefined(boolean val)
{
this.end_end_modifier_defined = val;
}
/**
Modifier optimization
*/
protected boolean getBeginStartModifierDefined()
{
return this.begin_start_modifier_defined;
}
/**
Modifier optimization
*/
protected boolean getBeginEndModifierDefined()
{
return this.begin_end_modifier_defined;
}
/**
Set the start tag character.
*/
public void setStartTagChar(char start_tag)
{
this.start_tag = start_tag;
}
/**
Get the start tag character.
*/
public char getStartTagChar()
{
return(start_tag);
}
/**
Set the end tag character.
*/
public void setEndTagChar(char end_tag)
{
this.end_tag = end_tag;
}
/**
Get the end tag character.
*/
public char getEndTagChar()
{
return(end_tag);
}
public String getTagText()
{
return(__text);
}
public Element setTagText(String text)
{
this.__text = (text);
return(this);
}
protected String createStartTag()
{
StringBuffer sb = new StringBuffer();
sb.append(getStartTagChar());
if(getBeginStartModifierDefined())
{
sb.append(getBeginStartModifier());
}
sb.append(getElementType());
if(getBeginEndModifierDefined())
{
sb.append(getBeginEndModifier());
}
sb.append(getEndTagChar());
return(sb.toString());
}
protected String createEndTag()
{
setEndStartModifier('/');
StringBuffer sb = new StringBuffer();
sb.append(getStartTagChar());
if(getEndStartModifierDefined())
{
sb.append(getEndStartModifier());
}
sb.append(getElementType());
if(getEndEndModifierDefined())
{
sb.append(getEndEndModifier());
}
sb.append(getEndTagChar());
return(sb.toString());
}
/**
Override toString() method to print something meaningful
*/
public final String toString()
{
String out = null;
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
output(bos);
bos.flush();
if ( getCodeSet() != null )
{
out = baos.toString(getCodeSet());
} else
{
out = baos.toString();
}
bos.close();
baos.close();
}
catch (IOException ioe)
{
}
return(out);
}
/**
Override toString(encode) method to print something meaningful
*/
public final String toString(String codeset)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
String out = null;
try
{
output(bos);
bos.flush();
out = baos.toString(codeset);
bos.close();
baos.close();
}
catch (UnsupportedEncodingException use)
{
}
catch (IOException ioe)
{
}
return(out);
}
/**
Add the element to the designated OutputStream.
*/
public void output(OutputStream out)
{
String encoding = null;
if ( getCodeSet() != null )
{
encoding = getCodeSet();
}
else
{
//By default use Big Endian Unicode.
//In this way we will not loose any information.
encoding = "UTF-16BE";
}
try
{
out.write(createStartTag().getBytes(encoding));
if(getFilterState())
out.write(getFilter().process(getTagText()).getBytes(encoding));
else
out.write(getTagText().getBytes(encoding));
if (getNeedClosingTag())
out.write(createEndTag().getBytes(encoding));
}
catch (UnsupportedEncodingException uee)
{
uee.printStackTrace(new PrintWriter(out));
}
catch (IOException ioe)
{
ioe.printStackTrace(new PrintWriter(out));
}
}
/**
Add element to the designated PrintWriter.
*/
public void output(PrintWriter out)
{
out.write(createStartTag());
if(getFilterState())
out.write(getFilter().process(getTagText()));
else
out.write(getTagText());
if (getNeedClosingTag())
out.write(createEndTag());
}
/**
Set the tab level for pretty printing
*/
public void setTabLevel(int tabLevel)
{
this.tabLevel = tabLevel;
}
public int getTabLevel()
{
return tabLevel;
}
protected void putTabs(int tabCount, OutputStream out)
throws IOException
{
for (int i = 0; i < tabCount; i++)
out.write('\t');
}
protected void putTabs(int tabCount, PrintWriter out)
{
for (int i = 0; i < tabCount; i++)
out.print('\t');
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -