1 23 24 package com.sun.enterprise.config.serverbeans.validation; 25 26 import java.util.Vector ; 27 import java.net.InetAddress ; 28 import java.net.UnknownHostException ; 29 import com.sun.enterprise.config.serverbeans.validation.tests.StaticTest; 30 31 43 44 45 46 public class AttrAddress extends AttrType { 47 48 public AttrAddress(String name, String type, boolean optional) { 49 super(name,type, optional); 50 } 51 52 public void validate(Object o, ValidationContext valCtx) { 53 super.validate(o, valCtx); String address = null; 55 if(o == null) 56 return; 57 if(o.equals("")) { 58 valCtx.result.failed(valCtx.smh.getLocalString(getClass().getName() + ".invalidNullStrAddress", 59 "Attribute({0}=null) : Null address not permitted", new Object []{valCtx.attrName})); 60 return; 61 } 62 address = (String )o; 63 try { 64 StaticTest.checkIPAddress(address); 65 } catch(UnknownHostException u) { 66 valCtx.result.failed(valCtx.smh.getLocalString(getClass().getName() + ".invalidAddress", 67 "Attribute({0}={1}) : Invalid address syntax - {1}", 68 new Object []{valCtx.attrName,address})); 69 } 70 } 71 72 } 73 | Popular Tags |