@Test(expected = ParseException.class) public void testParse01() throws ParseException { PortRange.newInstance("00-09-99"); }
public static PortRange newInstance(String stringPortRange) throws ParseException { if (stringPortRange == null) { return null; } String[] portParts = stringPortRange.split("[-]", -1); if (portParts == null || portParts.length == 0) { return null; } else if (portParts.length > 2) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": too many ranges", 0); } int[] rangeParts = new int[portParts.length]; try { for (int i = 0 ; i < portParts.length ; i++) { if (portParts[i].length() == 0) { rangeParts[i] = -1; } else { rangeParts[i] = Integer.parseInt(portParts[i]); } } } catch (NumberFormatException ex) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": invalid port number", 0); } if (rangeParts.length == 1) { return new PortRange(rangeParts[0], rangeParts[0]); } else { return new PortRange(rangeParts[0], rangeParts[1]); } }
PortRange implements SemanticString { public static PortRange newInstance(String stringPortRange) throws ParseException { if (stringPortRange == null) { return null; } String[] portParts = stringPortRange.split("[-]", -1); if (portParts == null || portParts.length == 0) { return null; } else if (portParts.length > 2) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": too many ranges", 0); } int[] rangeParts = new int[portParts.length]; try { for (int i = 0 ; i < portParts.length ; i++) { if (portParts[i].length() == 0) { rangeParts[i] = -1; } else { rangeParts[i] = Integer.parseInt(portParts[i]); } } } catch (NumberFormatException ex) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": invalid port number", 0); } if (rangeParts.length == 1) { return new PortRange(rangeParts[0], rangeParts[0]); } else { return new PortRange(rangeParts[0], rangeParts[1]); } } }
PortRange implements SemanticString { public static PortRange newInstance(String stringPortRange) throws ParseException { if (stringPortRange == null) { return null; } String[] portParts = stringPortRange.split("[-]", -1); if (portParts == null || portParts.length == 0) { return null; } else if (portParts.length > 2) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": too many ranges", 0); } int[] rangeParts = new int[portParts.length]; try { for (int i = 0 ; i < portParts.length ; i++) { if (portParts[i].length() == 0) { rangeParts[i] = -1; } else { rangeParts[i] = Integer.parseInt(portParts[i]); } } } catch (NumberFormatException ex) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": invalid port number", 0); } if (rangeParts.length == 1) { return new PortRange(rangeParts[0], rangeParts[0]); } else { return new PortRange(rangeParts[0], rangeParts[1]); } } PortRange(int portMinIn, int portMaxIn); }
PortRange implements SemanticString { public static PortRange newInstance(String stringPortRange) throws ParseException { if (stringPortRange == null) { return null; } String[] portParts = stringPortRange.split("[-]", -1); if (portParts == null || portParts.length == 0) { return null; } else if (portParts.length > 2) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": too many ranges", 0); } int[] rangeParts = new int[portParts.length]; try { for (int i = 0 ; i < portParts.length ; i++) { if (portParts[i].length() == 0) { rangeParts[i] = -1; } else { rangeParts[i] = Integer.parseInt(portParts[i]); } } } catch (NumberFormatException ex) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": invalid port number", 0); } if (rangeParts.length == 1) { return new PortRange(rangeParts[0], rangeParts[0]); } else { return new PortRange(rangeParts[0], rangeParts[1]); } } PortRange(int portMinIn, int portMaxIn); static PortRange newInstance(String stringPortRange); int getPortMin(); int getPortMax(); boolean contains(int port); @Override String stringValue(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
PortRange implements SemanticString { public static PortRange newInstance(String stringPortRange) throws ParseException { if (stringPortRange == null) { return null; } String[] portParts = stringPortRange.split("[-]", -1); if (portParts == null || portParts.length == 0) { return null; } else if (portParts.length > 2) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": too many ranges", 0); } int[] rangeParts = new int[portParts.length]; try { for (int i = 0 ; i < portParts.length ; i++) { if (portParts[i].length() == 0) { rangeParts[i] = -1; } else { rangeParts[i] = Integer.parseInt(portParts[i]); } } } catch (NumberFormatException ex) { throw new ParseException("Invalid PortRange \"" + stringPortRange + "\": invalid port number", 0); } if (rangeParts.length == 1) { return new PortRange(rangeParts[0], rangeParts[0]); } else { return new PortRange(rangeParts[0], rangeParts[1]); } } PortRange(int portMinIn, int portMaxIn); static PortRange newInstance(String stringPortRange); int getPortMin(); int getPortMax(); boolean contains(int port); @Override String stringValue(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }