Source Code Cross Referenced for AnySynapse.java in  » Web-Framework » anvil » anvil » core » brain » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » anvil » anvil.core.brain 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: AnySynapse.java,v 1.9 2002/09/16 08:05:02 jkl Exp $
003:         *
004:         * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
005:         *
006:         * Use is subject to license terms, as defined in
007:         * Anvil Sofware License, Version 1.1. See LICENSE 
008:         * file, or http://njet.org/license-1.1.txt
009:         */
010:        package anvil.core.brain;
011:
012:        import java.io.IOException;
013:        import java.io.Writer;
014:        import anvil.java.util.BindingEnumeration;
015:        import anvil.core.Any;
016:        import anvil.core.AnyAbstractClass;
017:        import anvil.core.AnyBindingEnumeration;
018:        import anvil.core.IndexedEnumeration;
019:        import anvil.script.Context;
020:        import anvil.script.Function;
021:        import anvil.core.Serializer;
022:        import anvil.core.Unserializer;
023:        import anvil.core.UnserializationException;
024:
025:        import anvil.brain.Synapse;
026:        import anvil.brain.Dimension;
027:        import anvil.server.OperationFailedException;
028:
029:        /// @class Synapse
030:        /// Synapse is object that contains abritrary attributes and 
031:        /// dimensions which are ordered lists linking this synapse to
032:        /// another synapses.
033:
034:        /// @attribute name
035:        /// @synopsis object <b>Synapse</b>.<i>name</i> ;
036:        /// Returns attribute given given name
037:        /// @synopsis object <b>Synapse</b>.<i>name</i> = <i>value</i> ;
038:        /// Sets the attribute given attribute to given value.
039:        /// @synopsis <b>delete Synapse</b>.<i>name</i> ;
040:        /// Removes attribute with given name.
041:
042:        /// @reference name
043:        /// @synopsis object <b>Synapse</b>[<i>name</i>] ;
044:        /// Returns attribute given given name
045:        /// @synopsis object <b>Synapse</b>[<i>name</i>] = <i>value</i> ;
046:        /// Sets the attribute given attribute to given value.
047:        /// @synopsis <b>delete Synapse</b>{<i>name</i>] ;
048:        /// Removes attribute with given name.
049:
050:        /// @operator enumeration
051:        /// Returns enumeration from attributes.
052:        /// @synopsis enumeration * <b>Synapse</b>
053:
054:        /**
055:         * class AnySynapse
056:         *
057:         * @author: Jani Lehtimäki
058:         */
059:        public class AnySynapse extends AnyAbstractClass {
060:
061:            public static final anvil.script.compiler.NativeClass __class__ = new anvil.script.compiler.NativeClass(
062:                    "Synapse",
063:                    AnySynapse.class,
064:                    //DOC{{
065:                    ""
066:                            + " @class Synapse\n"
067:                            + " Synapse is object that contains abritrary attributes and \n"
068:                            + " dimensions which are ordered lists linking this synapse to\n"
069:                            + " another synapses.\n"
070:                            + " @attribute name\n"
071:                            + " @synopsis object <b>Synapse</b>.<i>name</i> ;\n"
072:                            + " Returns attribute given given name\n"
073:                            + " @synopsis object <b>Synapse</b>.<i>name</i> = <i>value</i> ;\n"
074:                            + " Sets the attribute given attribute to given value.\n"
075:                            + " @synopsis <b>delete Synapse</b>.<i>name</i> ;\n"
076:                            + " Removes attribute with given name.\n"
077:                            + " @reference name\n"
078:                            + " @synopsis object <b>Synapse</b>[<i>name</i>] ;\n"
079:                            + " Returns attribute given given name\n"
080:                            + " @synopsis object <b>Synapse</b>[<i>name</i>] = <i>value</i> ;\n"
081:                            + " Sets the attribute given attribute to given value.\n"
082:                            + " @synopsis <b>delete Synapse</b>{<i>name</i>] ;\n"
083:                            + " Removes attribute with given name.\n"
084:                            + " @operator enumeration\n"
085:                            + " Returns enumeration from attributes.\n"
086:                            + " @synopsis enumeration * <b>Synapse</b>\n"
087:                            + " @method getID\n"
088:                            + " Returns the id of synapse.\n"
089:                            + " @synopsis int getID()\n"
090:                            + " @method getName\n"
091:                            + " Returns the name of synapse.\n"
092:                            + " @synopsis string getName()\n"
093:                            + " @method getType\n"
094:                            + " Returns the type of synapse.\n"
095:                            + " @synopsis string getType()\n"
096:                            + " @method setName\n"
097:                            + " Sets the name of synapse.\n"
098:                            + " @synopsis Dimension setName(string name)\n"
099:                            + " @method setType\n"
100:                            + " Sets the type of synapse.\n"
101:                            + " @synopsis Dimension setType(string name)\n"
102:                            + " @throws OperationFailed If an error occurred\n"
103:                            + " @method create\n"
104:                            + " Creates a new dimension.\n"
105:                            + " @synopsis Dimension create(string name)\n"
106:                            + " @throws OperationFailed If an error occurred\n"
107:                            + " @method dim\n"
108:                            + " Gets or creates dimension.\n"
109:                            + " @synopsis Dimension dim(string name)\n"
110:                            + " @throws OperationFailed If an error occurred\n"
111:                            + " @method get\n"
112:                            + " Gets a dimension with given name.\n"
113:                            + " @synopsis Dimension get(string name)\n"
114:                            + " @throws OperationFailed If an error occurred\n"
115:                            + " @method set\n"
116:                            + " Sets an attribute.\n"
117:                            + " @synopsis Synapse set(string name, object value)\n"
118:                            + " @throws OperationFailed If an error occurred\n"
119:                            + " @method remove\n" + " Removes a dimension.\n"
120:                            + " @synopsis void remove()\n"
121:                            + " @synopsis Synapse remove(string name)\n"
122:                            + " @throws OperationFailed If an error occurred\n"
123:                            + " @method dims\n"
124:                            + " Returns a enumeration of dimensions.\n"
125:                            + " @synopsis enumeration dims()\n"
126:                            + " @throws OperationFailed If an error occurred\n"
127:                            + " @method commit\n" + " Commits changes.\n"
128:                            + " @synopsis Synapse commit()\n"
129:                            + " @throws OperationFailed If an error occurred\n"
130:            //}}DOC
131:            );
132:            static {
133:                BrainModule.class.getName();
134:            }
135:
136:            private Synapse _synapse;
137:
138:            public AnySynapse(Synapse synapse) {
139:                _synapse = synapse;
140:            }
141:
142:            public final anvil.script.ClassType classOf() {
143:                return __class__;
144:            }
145:
146:            public String toString() {
147:                return _synapse.toString();
148:            }
149:
150:            public Object toObject() {
151:                return _synapse;
152:            }
153:
154:            public Any getAttribute(Context context, String attribute) {
155:                try {
156:                    return _synapse.getVariable(attribute);
157:                } catch (OperationFailedException e) {
158:                    throw context.exception(e);
159:                }
160:            }
161:
162:            public Any setAttribute(Context context, String attribute, Any value) {
163:                try {
164:                    _synapse.setVariable(attribute, value);
165:                    return this ;
166:                } catch (OperationFailedException e) {
167:                    throw context.exception(e);
168:                }
169:            }
170:
171:            public Any checkAttribute(Context context, String attribute) {
172:                try {
173:                    return _synapse.checkVariable(attribute);
174:                } catch (OperationFailedException e) {
175:                    throw context.exception(e);
176:                }
177:            }
178:
179:            public boolean deleteAttribute(Context context, String attribute) {
180:                try {
181:                    return _synapse.deleteVariable(attribute);
182:                } catch (OperationFailedException e) {
183:                    throw context.exception(e);
184:                }
185:            }
186:
187:            public Any getReference(Context context, Any index) {
188:                return getAttribute(context, index.toString());
189:            }
190:
191:            public Any setReference(Context context, Any index, Any value) {
192:                return setAttribute(context, index.toString(), value);
193:            }
194:
195:            public Any setReference(Context context, Any value) {
196:                return this ;
197:            }
198:
199:            public Any checkReference(Context context, Any index) {
200:                return checkAttribute(context, index.toString());
201:            }
202:
203:            public boolean deleteReference(Context context, Any index) {
204:                return deleteAttribute(context, index.toString());
205:            }
206:
207:            public BindingEnumeration enumeration() {
208:                try {
209:                    return _synapse.getVariables();
210:                } catch (OperationFailedException e) {
211:                    throw Context.getInstance().exception(e);
212:                }
213:            }
214:
215:            /// @method getID
216:            /// Returns the id of synapse.
217:            /// @synopsis int getID()
218:            public Any m_getID(Context context, Any[] parameters) {
219:                return Any.create(_synapse.getId());
220:            }
221:
222:            /// @method getName
223:            /// Returns the name of synapse.
224:            /// @synopsis string getName()
225:            public Any m_getName(Context context, Any[] parameters) {
226:                return Any.create(_synapse.getName());
227:            }
228:
229:            /// @method getType
230:            /// Returns the type of synapse.
231:            /// @synopsis string getType()
232:            public Any m_getType(Context context, Any[] parameters) {
233:                return Any.create(_synapse.getType());
234:            }
235:
236:            /// @method setName
237:            /// Sets the name of synapse.
238:            /// @synopsis Dimension setName(string name)
239:
240:            public Any m_setName(Context context, Any[] parameters) {
241:                if (parameters.length < 1) {
242:                    throw parametersMissing(context, "setName");
243:                }
244:                try {
245:                    _synapse.setName(parameters[0].toString());
246:                    return this ;
247:                } catch (OperationFailedException e) {
248:                    throw context.exception(e);
249:                }
250:            }
251:
252:            /// @method setType
253:            /// Sets the type of synapse.
254:            /// @synopsis Dimension setType(string name)
255:            /// @throws OperationFailed If an error occurred
256:            public Any m_setType(Context context, Any[] parameters) {
257:                if (parameters.length < 1) {
258:                    throw parametersMissing(context, "setType");
259:                }
260:                try {
261:                    _synapse.setType(parameters[0].toString());
262:                    return this ;
263:                } catch (OperationFailedException e) {
264:                    throw context.exception(e);
265:                }
266:            }
267:
268:            /// @method create
269:            /// Creates a new dimension.
270:            /// @synopsis Dimension create(string name)
271:            /// @throws OperationFailed If an error occurred
272:            public Any m_create(Context context, Any[] parameters) {
273:                if (parameters.length < 1) {
274:                    throw parametersMissing(context, "create");
275:                }
276:                try {
277:                    Dimension dim = _synapse.createDimension(parameters[0]
278:                            .toString());
279:                    return (dim != null) ? new AnyDimension(dim) : UNDEFINED;
280:                } catch (OperationFailedException e) {
281:                    throw context.exception(e);
282:                }
283:            }
284:
285:            /// @method dim
286:            /// Gets or creates dimension.
287:            /// @synopsis Dimension dim(string name)
288:            /// @throws OperationFailed If an error occurred
289:            public Any m_dim(Context context, Any[] parameters) {
290:                if (parameters.length < 1) {
291:                    throw parametersMissing(context, "dim");
292:                }
293:                try {
294:                    Dimension dim = _synapse.getOrCreateDimension(parameters[0]
295:                            .toString());
296:                    return (dim != null) ? new AnyDimension(dim) : UNDEFINED;
297:                } catch (OperationFailedException e) {
298:                    throw context.exception(e);
299:                }
300:            }
301:
302:            /// @method get
303:            /// Gets a dimension with given name.
304:            /// @synopsis Dimension get(string name)
305:            /// @throws OperationFailed If an error occurred
306:            public Any m_get(Context context, Any[] parameters) {
307:                if (parameters.length < 1) {
308:                    throw parametersMissing(context, "get");
309:                }
310:                try {
311:                    Dimension dim = _synapse.getDimension(parameters[0]
312:                            .toString());
313:                    return (dim != null) ? new AnyDimension(dim) : UNDEFINED;
314:                } catch (OperationFailedException e) {
315:                    throw context.exception(e);
316:                }
317:            }
318:
319:            /// @method set
320:            /// Sets an attribute.
321:            /// @synopsis Synapse set(string name, object value)
322:            /// @throws OperationFailed If an error occurred
323:            public Any m_set(Context context, Any[] parameters) {
324:                if (parameters.length < 2) {
325:                    throw parametersMissing(context, "set");
326:                }
327:                try {
328:                    _synapse.setVariable(parameters[0].toString(),
329:                            parameters[1]);
330:                    return this ;
331:                } catch (OperationFailedException e) {
332:                    throw context.exception(e);
333:                }
334:            }
335:
336:            /// @method remove
337:            /// Removes a dimension.
338:            /// @synopsis void remove()
339:            /// @synopsis Synapse remove(string name)
340:            /// @throws OperationFailed If an error occurred
341:            public Any m_remove(Context context, Any[] parameters) {
342:                try {
343:                    if (parameters.length == 0) {
344:                        _synapse.remove();
345:                        return NULL;
346:                    } else {
347:                        _synapse.removeDimension(parameters[0].toString());
348:                        return this ;
349:                    }
350:                } catch (OperationFailedException e) {
351:                    throw context.exception(e);
352:                }
353:            }
354:
355:            /// @method dims
356:            /// Returns a enumeration of dimensions.
357:            /// @synopsis enumeration dims()
358:            /// @throws OperationFailed If an error occurred
359:            public Any m_dims(Context context, Any[] parameters) {
360:                try {
361:                    return new AnyBindingEnumeration(new IndexedEnumeration(
362:                            _synapse.getDimensions()));
363:                } catch (OperationFailedException e) {
364:                    throw context.exception(e);
365:                }
366:            }
367:
368:            /* @method links
369:             @synopsis enumeration links()
370:            public Any m  _links(Context context, Any[] parameters)
371:            {
372:              final Dimension[] dim = _synapse.getReferers();
373:              return new AnyBindingEnumeration(new BindingEnumeration() 
374:                {
375:                  int _index = 0;
376:                  public boolean hasMoreElements() 
377:                  {
378:                    return _index < dim.length;
379:                  }
380:                  public Object nextKey()
381:                  {
382:                    return Any.create(_index);
383:                  }
384:                  public Object nextElement()
385:                  {
386:                    return new AnyDimension(dim[_index++]);
387:                  }
388:                }
389:              );
390:            }*/
391:
392:            /// @method commit
393:            /// Commits changes.
394:            /// @synopsis Synapse commit()
395:            /// @throws OperationFailed If an error occurred
396:            public Any m_commit(Context context, Any[] parameters) {
397:                try {
398:                    _synapse.commit();
399:                    return this ;
400:                } catch (OperationFailedException e) {
401:                    throw context.exception(e);
402:                }
403:            }
404:
405:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.