📄 out.java
字号:
/* Out.java{{IS_NOTE Purpose: Description: History: Tue Sep 6 16:10:51 2005, Created by tomyeh}}IS_NOTECopyright (C) 2005 Potix Corporation. All Rights Reserved.{{IS_RIGHT This program is distributed under GPL Version 2.0 in the hope that it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*/package org.zkoss.web.servlet.dsp.action;import java.io.IOException;import org.zkoss.web.mesg.MWeb;import org.zkoss.web.servlet.ServletException;import org.zkoss.xml.XMLs;/** * Generates the specified value into a string. * * @author tomyeh */public class Out extends AbstractAction { private String _value = null; private int _maxlength = 0; private boolean _escapeXML = true; /** Returns whether to escape XML. * Default: true. */ public boolean getEscapeXML() { return _escapeXML; } /** Sets whether to escape XML. */ public void setEscapeXML(boolean escapeXML) { _escapeXML = escapeXML; } /** Returns the value. * Default: null. */ public String getValue() { return _value; } /** Sets the value. */ public void setValue(String value) { _value = value; } /** Returns the maxlength of bytes to output. * <p>Default: 0 (no limit). */ public int getMaxlength() { return _maxlength; } /** Sets the maxlength to output. */ public void setMaxlength(int maxlength) { _maxlength = maxlength; } //-- Action --// public void render(ActionContext ac, boolean nested) throws javax.servlet.ServletException, IOException { if (!isEffective()) return; if (nested) throw new ServletException(MWeb.DSP_NESTED_ACTION_NOT_ALLOWED, new Object[] {this, new Integer(ac.getLineNumber())}); if (_value == null) return; int len = _value.length(); if (len == 0) return; String value = _value; if (_maxlength > 0 && len > _maxlength) { int j = _maxlength; while (j > 0 && Character.isWhitespace(value.charAt(j - 1))) --j; value = value.substring(0, j) + "..."; } if (_escapeXML) { StringBuffer sb = null; len = value.length(); for (int j = 0; j < len; ++j) { final char cc = value.charAt(j); final String replace = _escapeXML ? XMLs.escapeXML(cc): null; if (replace != null) { if (sb == null) { sb = new StringBuffer(value.length() + 10); sb.append(value.substring(0, j)); } sb.append(replace); } else if (sb != null) { sb.append(cc); } } if (sb != null) value = sb.toString(); } ac.getOut().write(value); } //-- Object --// public String toString() { return "out"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -