001/* 002 * Copyright (C) 2005 Christian Schulte <cs@schulte.it> 003 * All rights reserved. 004 * 005 * Redistribution and use in source and binary forms, with or without 006 * modification, are permitted provided that the following conditions 007 * are met: 008 * 009 * o Redistributions of source code must retain the above copyright 010 * notice, this list of conditions and the following disclaimer. 011 * 012 * o Redistributions in binary form must reproduce the above copyright 013 * notice, this list of conditions and the following disclaimer in 014 * the documentation and/or other materials provided with the 015 * distribution. 016 * 017 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 018 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 019 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 020 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, 021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 022 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 023 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 024 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 025 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 026 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 027 * 028 * $JOMC: ResourceType.java 5135 2016-04-08 13:53:07Z schulte $ 029 * 030 */ 031package org.jomc.mojo; 032 033import org.apache.commons.lang.builder.ToStringBuilder; 034 035/** 036 * Datatype describing a resource. 037 * 038 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 039 * @version $JOMC: ResourceType.java 5135 2016-04-08 13:53:07Z schulte $ 040 * @since 1.2 041 */ 042public class ResourceType implements Cloneable 043{ 044 045 /** 046 * The location of the resource. 047 */ 048 private String location; 049 050 /** 051 * Flag indicating the resource is optional. 052 */ 053 private boolean optional; 054 055 /** 056 * Timeout value, in milliseconds, to be used when opening communications links to the resource. 057 */ 058 private int connectTimeout = 60000; 059 060 /** 061 * Timeout value, in milliseconds, to be used when reading the resource. 062 */ 063 private int readTimeout = 60000; 064 065 /** 066 * Creates a new {@code ResourceType} instance. 067 */ 068 public ResourceType() 069 { 070 super(); 071 } 072 073 /** 074 * Gets the value of the {@code location} property. 075 * 076 * @return The value of the {@code location} property. 077 */ 078 public final String getLocation() 079 { 080 return this.location; 081 } 082 083 /** 084 * Sets the value of the {@code location} property. 085 * 086 * @param value The value of the {@code location} property. 087 */ 088 public final void setLocation( final String value ) 089 { 090 this.location = value; 091 } 092 093 /** 094 * Gets a flag indicating the resource is optional. 095 * 096 * @return {@code true}, if the resource is optional; {@code false}, if the build fails when the resource is not 097 * found. 098 */ 099 public final boolean isOptional() 100 { 101 return this.optional; 102 } 103 104 /** 105 * Sets the flag indicating the resource is optional. 106 * 107 * @param value {@code true}, to flag the resource optional; {@code false}, to fail the build when the resource is 108 * not found. 109 */ 110 public final void setOptional( final boolean value ) 111 { 112 this.optional = value; 113 } 114 115 /** 116 * Gets the timeout value, in milliseconds, to be used when opening communications links to the resource. 117 * A timeout of zero is interpreted as an infinite timeout. 118 * 119 * @return The timeout value, in milliseconds, to be used when opening communications links to the resource. 120 */ 121 public final int getConnectTimeout() 122 { 123 return this.connectTimeout; 124 } 125 126 /** 127 * Sets the timeout value, in milliseconds, to be used when opening communications links to the resource. 128 * A timeout of zero is interpreted as an infinite timeout. 129 * 130 * @param value The new timeout value, in milliseconds, to be used when opening communications links to the 131 * resource. 132 */ 133 public final void setConnectTimeout( final int value ) 134 { 135 this.connectTimeout = value; 136 } 137 138 /** 139 * Gets the timeout value, in milliseconds, to be used when reading the resource. A timeout of zero is interpreted 140 * as an infinite timeout. 141 * 142 * @return The timeout value, in milliseconds, to be used when reading the resource. 143 */ 144 public final int getReadTimeout() 145 { 146 return this.readTimeout; 147 } 148 149 /** 150 * Sets the timeout value, in milliseconds, to be used when reading the resource. A timeout of zero is interpreted 151 * as an infinite timeout. 152 * 153 * @param value The new timeout value, in milliseconds, to be used when reading the resource. 154 */ 155 public final void setReadTimeout( final int value ) 156 { 157 this.readTimeout = value; 158 } 159 160 /** 161 * Creates and returns a copy of this object. 162 * 163 * @return A copy of this object. 164 */ 165 @Override 166 public ResourceType clone() 167 { 168 try 169 { 170 return (ResourceType) super.clone(); 171 } 172 catch ( final CloneNotSupportedException e ) 173 { 174 throw new AssertionError( e ); 175 } 176 } 177 178 /** 179 * Creates and returns a string representation of the object. 180 * 181 * @return A string representation of the object. 182 */ 183 @Override 184 public String toString() 185 { 186 return ToStringBuilder.reflectionToString( this ); 187 } 188 189}