| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.serialize; |
| 9 | |
| 10 | import java.io.Writer; |
| 11 | |
| 12 | /** |
| 13 | * A class that represents a character as a hexadecimal character reference |
| 14 | * and writes the result to a supplied Writer |
| 15 | */ |
| 16 | |
| 17 | public class HexCharacterReferenceGenerator implements CharacterReferenceGenerator { |
| 18 | |
| 19 | public final static HexCharacterReferenceGenerator THE_INSTANCE = new HexCharacterReferenceGenerator(); |
| 20 | |
| 21 | private HexCharacterReferenceGenerator() { |
| 22 | } |
| 23 | |
| 24 | public void outputCharacterReference(int charval, Writer writer) throws java.io.IOException { |
| 25 | writer.write("&#x"); |
| 26 | writer.write(Integer.toHexString(charval)); |
| 27 | writer.write(';'); |
| 28 | } |
| 29 | } |
| 30 |