1 38 package com.gargoylesoftware.htmlunit; 39 40 47 public final class SubmitMethod { 48 51 public static final SubmitMethod POST = new SubmitMethod( "post" ); 52 55 public static final SubmitMethod GET = new SubmitMethod( "get" ); 56 57 private final String name_; 58 59 60 private SubmitMethod( final String name ) { 61 name_ = name; 62 } 63 64 65 70 public String getName() { 71 return name_; 72 } 73 74 75 81 public static SubmitMethod getInstance( final String name ) { 82 final String lowerCaseName = name.toLowerCase(); 83 final SubmitMethod allInstances[] = new SubmitMethod[]{POST, GET}; 84 85 int i; 86 for( i = 0; i < allInstances.length; i++ ) { 87 if( allInstances[i].getName().equals( lowerCaseName ) ) { 88 return allInstances[i]; 89 } 90 } 91 92 if( name.equals( "" ) ) { 94 return GET; 95 } 96 97 throw new IllegalArgumentException ( "No method found for [" + name + "]" ); 98 } 99 100 101 106 public String toString() { 107 return "SubmitMethod[name=" + getName() + "]"; 108 } 109 } 110 111 | Popular Tags |