KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > metadata > MethodAttributes


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.metadata;
23
24 /**
25  *
26  * Provides meta-data for method-attributes
27  * <method-attributes>
28  * <method>
29  * <method-name>get*</method-name>
30  * <read-only>true</read-only>
31  * <idempotent>true</idempotent>
32  * <transaction-timeout>100</tranaction-timeout>
33  * </method>
34  * </method-attributes>
35  *
36  * @author <a HREF="pete@subx.com">Peter Murray</a>
37  *
38  * @version $Revision: 58231 $
39  *
40  * <p><b>Revisions:</b><br>
41  * <p><b>2001/04/10: peter</b>
42  * <ol>
43  * <li>Initial revision
44  * </ol>
45  */

46 public class MethodAttributes
47 {
48    String JavaDoc pattern;
49    boolean readOnly;
50    boolean idempotent;
51    int txTimeout;
52
53    public static MethodAttributes kDefaultMethodAttributes;
54
55    static
56    {
57       kDefaultMethodAttributes = new MethodAttributes();
58       kDefaultMethodAttributes.pattern = "*";
59       kDefaultMethodAttributes.readOnly = false;
60       kDefaultMethodAttributes.idempotent = false;
61       kDefaultMethodAttributes.txTimeout = 0;
62    }
63
64    public void setPattern(String JavaDoc pattern)
65    {
66       this.pattern = pattern;
67    }
68
69    public void setReadOnly(boolean readOnly)
70    {
71       this.readOnly = readOnly;
72    }
73
74    public void setIdempotent(boolean idempotent)
75    {
76       this.idempotent = idempotent;
77    }
78
79    public void setTxTimeout(int txTimeout)
80    {
81       this.txTimeout = txTimeout;
82    }
83
84    public boolean patternMatches(String JavaDoc methodName)
85    {
86       int ct, end;
87
88       end = pattern.length();
89
90       if(end > methodName.length())
91           return false;
92
93       for(ct = 0; ct < end; ct ++)
94       {
95          char c = pattern.charAt(ct);
96          if(c == '*')
97         return true;
98          if(c != methodName.charAt(ct))
99         return false;
100       }
101       return ct == methodName.length();
102    }
103
104    public boolean isReadOnly()
105    {
106       return readOnly;
107    }
108
109    public boolean isIdempotent()
110    {
111       return idempotent;
112    }
113
114    public int getTransactionTimeout()
115    {
116       return txTimeout;
117    }
118 }
119
Popular Tags