
net.darkmist.alib.escape.CSS Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2012 Ed Schaller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package net.darkmist.alib.escape;
import java.io.IOException;
public class CSS extends Escaper.Abstract
{
private static final CSS SINGLETON = new CSS();
private static final StrMaker MAKER = CSSEscapeMaker.instance();
private CSS()
{
}
public static CSS instance()
{
return SINGLETON;
}
@Override
public Appendable escape(Appendable appendable, int ch) throws IOException
{
switch(ch)
{
case 0:
throw new IllegalArgumentException("Chracter value zero is not valid in CSS");
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case ' ':
case '\t':
case '\r':
case '\n':
return appendable.append((char)ch);
}
if(ch < 0)
throw new IllegalArgumentException("Negative code point " + ch);
return MAKER.appendStr(appendable, ch);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy