sun.net.idn.StringPrep Java Examples
The following examples show how to use
sun.net.idn.StringPrep.
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 File: NFS4StringPrep.java From openjdk-8 with 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 #2
Source File: TestStringPrep.java From openjdk-jdk9 with 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 #3
Source File: NFS4StringPrep.java From jdk8u-jdk with 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 #4
Source File: NFS4StringPrep.java From dragonwell8_jdk with 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 File: TestStringPrep.java From jdk8u-jdk with 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 #6
Source File: NFS4StringPrep.java From hottub with 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 #7
Source File: NFS4StringPrep.java From hottub with 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 #8
Source File: TestStringPrep.java From hottub with 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 #9
Source File: NFS4StringPrep.java From openjdk-8-source with 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 #10
Source File: NFS4StringPrep.java From openjdk-8-source with 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 #11
Source File: TestStringPrep.java From openjdk-8-source with 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 #12
Source File: NFS4StringPrep.java From openjdk-8 with 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 #13
Source File: NFS4StringPrep.java From jdk8u-jdk with 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 #14
Source File: TestStringPrep.java From openjdk-8 with 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 #15
Source File: NFS4StringPrep.java From jdk8u_jdk with 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 #16
Source File: NFS4StringPrep.java From jdk8u_jdk with 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 #17
Source File: TestStringPrep.java From jdk8u_jdk with 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 #18
Source File: NFS4StringPrep.java From jdk8u-jdk with 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 #19
Source File: NFS4StringPrep.java From jdk8u-jdk with 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 #20
Source File: TestStringPrep.java From jdk8u-jdk with 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 #21
Source File: NFS4StringPrep.java From jdk8u-dev-jdk with 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 #22
Source File: NFS4StringPrep.java From jdk8u-dev-jdk with 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 #23
Source File: TestStringPrep.java From jdk8u-dev-jdk with 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 #24
Source File: NFS4StringPrep.java From TencentKona-8 with 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 #25
Source File: TestStringPrep.java From TencentKona-8 with 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 #26
Source File: NFS4StringPrep.java From jdk8u60 with 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 #27
Source File: NFS4StringPrep.java From TencentKona-8 with 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 #28
Source File: NFS4StringPrep.java From jdk8u60 with 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 #29
Source File: TestStringPrep.java From jdk8u60 with 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 #30
Source File: NFS4StringPrep.java From openjdk-jdk9 with 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"); }