Java Code Examples for sun.net.idn.StringPrep
The following examples show how to use
sun.net.idn.StringPrep. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dragonwell8_jdk Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 2
Source Project: dragonwell8_jdk Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 3
Source Project: dragonwell8_jdk Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 4
Source Project: TencentKona-8 Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 5
Source Project: TencentKona-8 Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 6
Source Project: TencentKona-8 Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 7
Source Project: jdk8u60 Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 8
Source Project: jdk8u60 Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 9
Source Project: jdk8u60 Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 10
Source Project: openjdk-jdk8u Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 11
Source Project: openjdk-jdk8u Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 12
Source Project: openjdk-jdk8u Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 13
Source Project: openjdk-jdk8u-backup Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 14
Source Project: openjdk-jdk8u-backup Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 15
Source Project: openjdk-jdk8u-backup Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 16
Source Project: openjdk-jdk9 Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 17
Source Project: openjdk-jdk9 Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 18
Source Project: openjdk-jdk9 Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getModule() .getResourceAsStream("sun/net/idn/uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 19
Source Project: jdk8u-jdk Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 20
Source Project: jdk8u-jdk Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 21
Source Project: jdk8u-jdk Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 22
Source Project: hottub Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 23
Source Project: hottub Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 24
Source Project: hottub Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 25
Source Project: openjdk-8-source Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 26
Source Project: openjdk-8-source Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 27
Source Project: openjdk-8-source Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }
Example 28
Source Project: openjdk-8 Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
private NFS4StringPrep (){ ClassLoader loader = NFS4StringPrep.class.getClassLoader(); try{ InputStream nfscsiFile = loader.getResourceAsStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); InputStream nfscssFile = loader.getResourceAsStream("nfscss.spp"); nfscss = new StringPrep(nfscssFile); nfscssFile.close(); InputStream nfscisFile = loader.getResourceAsStream("nfscis.spp"); nfscis = new StringPrep(nfscisFile); nfscisFile.close(); InputStream nfsmxpFile = loader.getResourceAsStream("nfsmxp.spp"); nfsmxp = new StringPrep(nfsmxpFile); nfsmxpFile.close(); InputStream nfsmxsFile = loader.getResourceAsStream("nfsmxs.spp"); nfsmxs = new StringPrep(nfsmxsFile); nfsmxsFile.close(); }catch(IOException e){ throw new RuntimeException(e.toString()); } }
Example 29
Source Project: openjdk-8 Source File: NFS4StringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static byte[] mixed_prepare(byte[] src) throws IOException, ParseException, UnsupportedEncodingException{ String s = new String(src, "UTF-8"); int index = s.indexOf(AT_SIGN); StringBuffer out = new StringBuffer(); if(index > -1){ /* special prefixes must not be followed by suffixes! */ String prefixString = s.substring(0,index); int i= findStringIndex(special_prefixes, prefixString); String suffixString = s.substring(index+1, s.length()); if(i>-1 && !suffixString.equals("")){ throw new ParseException("Suffix following a special index", -1); } UCharacterIterator prefix = UCharacterIterator.getInstance(prefixString); UCharacterIterator suffix = UCharacterIterator.getInstance(suffixString); out.append(prep.nfsmxp.prepare(prefix,StringPrep.DEFAULT)); out.append(AT_SIGN); // add the delimiter out.append(prep.nfsmxs.prepare(suffix, StringPrep.DEFAULT)); }else{ UCharacterIterator iter = UCharacterIterator.getInstance(s); out.append(prep.nfsmxp.prepare(iter,StringPrep.DEFAULT)); } return out.toString().getBytes("UTF-8"); }
Example 30
Source Project: openjdk-8 Source File: TestStringPrep.java License: GNU General Public License v2.0 | 6 votes |
public static void TestNamePrepConformance() throws Exception { InputStream stream = StringPrep.class.getResourceAsStream("uidna.spp"); StringPrep namePrep = new StringPrep(stream); stream.close(); int i; for(i=0; i<TestData.conformanceTestCases.length;i++){ TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i]; try{ UCharacterIterator iter = UCharacterIterator.getInstance(testCase.input); StringBuffer output = namePrep.prepare(iter, testCase.flags); if(testCase.output !=null && output!=null && !testCase.output.equals(output.toString())){ fail("Did not get the expected output. Expected: " + prettify(testCase.output)+ " Got: "+ prettify(output.toString()) ); } } catch(ParseException ex) { if (testCase.expected == null) { fail("get the unexpected exception for source: " +testCase.input +" Got: "+ ex.toString()); } } } System.out.println("Nameprep test count: " + i); }