Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

TEntity.java

00001 /*
00002 *  Name:      TEntity.java
00003 *  Author:    Francisco Vides Fernández
00004 *  Summary:   class for manipulating html entities
00005 *  Date:      $Date: 2003/10/02 22:25:06 $
00006 *  Revision:  $Revision: 1.2 $
00007 *
00008 *  Copyright (C) 2001-2003  Dedalo Ingenieros, S.L.
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00027 package org.mpcl.text.html;
00028 
00029 import java.text.StringCharacterIterator;
00030 
00031 
00032 public class TEntity
00033 {
00034 
00035   public static String _encodeCharacters (String ySOURCE)
00036   {
00037 
00038     StringCharacterIterator   I;
00039     StringBuffer              yEncodedSource = null;
00040 
00041     if ( ySOURCE != null )
00042     {
00043       I              = new StringCharacterIterator (ySOURCE);
00044       yEncodedSource = new StringBuffer();
00045       for (char cSOURCE = I.first(); ( cSOURCE != StringCharacterIterator.DONE ) ;cSOURCE = I.next())
00046       {
00047         switch (cSOURCE)
00048         {
00049           case '<' : yEncodedSource.append ("&lt;");          break;
00050           case '>' : yEncodedSource.append ("&gt;");          break;
00051           case '\u00e1' : yEncodedSource.append ("&aacute;"); break;
00052           case '\u00e9' : yEncodedSource.append ("&eacute;"); break;
00053           case '\u00ed' : yEncodedSource.append ("&iacute;"); break;
00054           case '\u00f3' : yEncodedSource.append ("&oacute;"); break;
00055           case '\u00fa' : yEncodedSource.append ("&uacute;"); break;
00056           case '\u00c1' : yEncodedSource.append ("&Aacute;"); break;
00057           case '\u00c9' : yEncodedSource.append ("&Eacute;"); break;
00058           case '\u00cd' : yEncodedSource.append ("&Iacute;"); break;
00059           case '\u00d3' : yEncodedSource.append ("&Oacute;"); break;
00060           case '\u00da' : yEncodedSource.append ("&Uacute;"); break;
00061           case '"' : yEncodedSource.append ("&quot;");        break;
00062           case '\'': yEncodedSource.append ("&apos;");        break;
00063           case '&' : yEncodedSource.append ("&amp;");         break;
00064           case '\u00f1': yEncodedSource.append ("&ntilde");   break;
00065           case '\u00d1' : yEncodedSource.append ("&Ntilde;"); break;
00066           default: yEncodedSource.append (cSOURCE);           break;
00067         }
00068       }
00069     }
00070     return yEncodedSource.toString();
00071 
00072   }  // _encodeCharacters()
00073 
00074 }  // class TEntity

Generated on Mon Oct 13 02:35:24 2003 for MPCL by doxygen1.2.18