Source Code Cross Referenced for Reference.java in  » Scripting » oscript-2.10.4 » oscript » data » 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 » Scripting » oscript 2.10.4 » oscript.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*=============================================================================
002:         *     Copyright Texas Instruments 2000-2004.  All Rights Reserved.
003:         *   
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         * 
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         * 
018:         * $ProjectHeader: OSCRIPT 0.155 Fri, 20 Dec 2002 18:34:22 -0800 rclark $
019:         */
020:
021:        package oscript.data;
022:
023:        import oscript.exceptions.*;
024:        import oscript.util.StackFrame;
025:        import oscript.util.MemberTable;
026:
027:        /**
028:         * A reference forwards all method calls to the object it is a reference
029:         * for, but additionally a reference is assignable.  It is used when a
030:         * variable (or array element) is looked up within a scope, and can be
031:         * used as either an lval or rval.
032:         * <p>
033:         * When a property of an object (ie a scope) has attributes associated
034:         * with it, those attributes are attributes of the reference.  The
035:         * attributes are partially enforced by this class (in the case of 
036:         * "const"), and by <code>ScriptObject</code> (in the case of "public").
037:         * <p>
038:         * Note that this could extends {@link AbstractReference}, but doesn't
039:         * because I think that would have a performance impact... one of these
040:         * days I should actually verify that...
041:         * 
042:         * @author Rob Clark (rob@ti.com)
043:         */
044:        public final class Reference extends Value {
045:            /**
046:             */
047:            public static final int ATTR_INVALID = -1;
048:            public static final int ATTR_PRIVATE = 0x01000000;
049:            public static final int ATTR_PROTECTED = 0x02000000;
050:            public static final int ATTR_PUBLIC = 0x04000000;
051:            public static final int ATTR_CONST = 0x10000000;
052:            public static final int ATTR_STATIC = 0x20000000 | ATTR_PUBLIC; // XXX for now static is also public
053:
054:            /**
055:             * The attribute bit-mask, either {@link #ATTR_INVALID} or a mask of the
056:             * other attribute constants.
057:             */
058:            private int attr;
059:            private boolean readonly;
060:            private Value val;
061:
062:            /*=======================================================================*/
063:            /**
064:             * Class Constructor.  Create a reference with the default attributes.
065:             */
066:            public Reference() {
067:                this (ATTR_INVALID);
068:            }
069:
070:            /*=======================================================================*/
071:            /**
072:             * Copy Constructor
073:             */
074:            public Reference(Reference r) {
075:                this (r.attr);
076:                this .val = r.val;
077:                this .readonly = r.readonly;
078:            }
079:
080:            /*=======================================================================*/
081:            /**
082:             * Class Constructor.  Create a reference with the specified attributes.
083:             * 
084:             * @param attr         attribute bitmask
085:             */
086:            public Reference(int attr) {
087:                super ();
088:                reset(attr);
089:            }
090:
091:            /*=======================================================================*/
092:            /**
093:             * Get the type of this object.  The returned type doesn't have to take
094:             * into account the possibility of a script type extending a built-in
095:             * type, since that is handled by {@link #getType}.
096:             * 
097:             * @return the object's type
098:             */
099:            protected Value getTypeImpl() {
100:                return Type.HIDDEN_TYPE;
101:            }
102:
103:            /*=======================================================================*/
104:            /**
105:             * Get access to this reference's attributes.
106:             */
107:            int getAttr() {
108:                return attr;
109:            }
110:
111:            /*=======================================================================*/
112:            /**
113:             * Reset this reference, which is used when the reference is re-used (in-
114:             * stead of re-allocating)
115:             */
116:            final void reset(int attr) {
117:                this .attr = attr;
118:                this .val = UNDEFINED;
119:                this .readonly = false;
120:            }
121:
122:            public final void reset(Value val) {
123:                this .attr = ATTR_PUBLIC;
124:                this .val = val.unhand();
125:                this .readonly = false;
126:            }
127:
128:            public final void reset() {
129:                this .attr = ATTR_INVALID;
130:                this .val = UNDEFINED;
131:                this .readonly = false;
132:            }
133:
134:            /*=======================================================================*/
135:            /**
136:             * Return a hash code value for this object.
137:             * 
138:             * @return a hash code value
139:             * @see java.lang.Object#hashCode()
140:             */
141:            public int hashCode() {
142:                return val.hashCode();
143:            }
144:
145:            /*=======================================================================*/
146:            /**
147:             * Compare two objects for equality.
148:             * 
149:             * @param obj          the object to compare to this object
150:             * @return <code>true</code> if equals, else <code>false</code>
151:             * @see java.lang.Object#equals(java.lang.Object)
152:             */
153:            public boolean equals(Object obj) {
154:                return val.equals(obj);
155:            }
156:
157:            /*=======================================================================*/
158:            /**
159:             * Determine if this reference is public.  This is used by ScriptObject to
160:             * determine if it should restrict access to this reference.
161:             * 
162:             * @return <code>true</code> if public, else <code>false</code>
163:             */
164:            boolean isPublic() {
165:                return (attr & ATTR_PUBLIC) != 0;
166:            }
167:
168:            /*=======================================================================*/
169:            /**
170:             * For references to an object (ie variables), this returns the actual
171:             * value this is a reference to, otherwise this return <code>this</code>.
172:             * 
173:             * @return the actual object
174:             */
175:            public Value unhand() {
176:                return val.unhand();
177:            }
178:
179:            /*=======================================================================*/
180:            /**
181:             * Return the object used for implementing <i>synchronized</i>.  For a
182:             * normal script object, the object is it's own monitor.  For a java
183:             * object, it is the java object rather than the {@link JavaObjectWrapper}.
184:             * 
185:             * @return the object to synchronize on
186:             */
187:            public Object getMonitor() {
188:                return val.getMonitor();
189:            }
190:
191:            /*=======================================================================*/
192:            /**
193:             * If this object is a type, determine if an instance of this type is
194:             * an instance of the specified type, ie. if this is <code>type</code>,
195:             * or a subclass.
196:             * 
197:             * @param type         the type to compare this type to
198:             * @return <code>true</code> or <code>false</code>
199:             * @throws PackagedScriptObjectException(NoSuchMemberException)
200:             */
201:            public boolean isA(Value type) {
202:                return val.isA(type);
203:            }
204:
205:            /*=======================================================================*/
206:            /**
207:             * Get the type of this object.  A reference doesn't actually have a type,
208:             * but instead is the type of whatever it contains... really I am not sure
209:             * if a reference is a first class type, or perhaps could be implemented
210:             * as an inner-class for OArray and ScriptObject.  Perhaps Value should be
211:             * an interface, and what is now Value becomes some sort of adapter
212:             * class?
213:             * 
214:             * @return the object's type
215:             */
216:            public Value getType() {
217:                return val.getType();
218:            }
219:
220:            /*=======================================================================*/
221:            /* Casting methods:
222:             */
223:
224:            /*=======================================================================*/
225:            /**
226:             * Convert this object to a native java <code>boolean</code> value.
227:             * 
228:             * @return a boolean value
229:             * @throws PackagedScriptObjectException(NoSuchMemberException)
230:             */
231:            public boolean castToBoolean() throws PackagedScriptObjectException {
232:                return val.castToBoolean();
233:            }
234:
235:            /*=======================================================================*/
236:            /**
237:             * Convert this object to a native java <code>String</code> value.
238:             * 
239:             * @return a String value
240:             * @throws PackagedScriptObjectException(NoSuchMemberException)
241:             */
242:            public String castToString() throws PackagedScriptObjectException {
243:                return val.castToString();
244:            }
245:
246:            /*=======================================================================*/
247:            /**
248:             * Convert this object to a native java <code>long</code> value.
249:             * 
250:             * @return a long value
251:             * @throws PackagedScriptObjectException(NoSuchMemberException)
252:             */
253:            public long castToExactNumber()
254:                    throws PackagedScriptObjectException {
255:                return val.castToExactNumber();
256:            }
257:
258:            /*=======================================================================*/
259:            /**
260:             * Convert this object to a native java <code>double</code> value.
261:             * 
262:             * @return a double value
263:             * @throws PackagedScriptObjectException(NoSuchMemberException)
264:             */
265:            public double castToInexactNumber()
266:                    throws PackagedScriptObjectException {
267:                return val.castToInexactNumber();
268:            }
269:
270:            /*=======================================================================*/
271:            /**
272:             * Convert this object to a native java <code>Object</code> value.
273:             * 
274:             * @return a java object
275:             * @throws PackagedScriptObjectException(NoSuchMemberException)
276:             */
277:            public Object castToJavaObject()
278:                    throws PackagedScriptObjectException {
279:                return val.castToJavaObject();
280:            }
281:
282:            /*=======================================================================*/
283:            /* The binary operators:
284:             */
285:
286:            /*=======================================================================*/
287:            /**
288:             * Perform the cast operation, <code>(a)b</code> is equivalent to <code>a.bopCast(b)</code>
289:             * 
290:             * @param val          the other value
291:             * @return the result
292:             * @throws PackagedScriptObjectException(NoSuchMemberException)
293:             */
294:            public Value bopCast(Value val)
295:                    throws PackagedScriptObjectException {
296:                return this .val.bopCast(val);
297:            }
298:
299:            public Value bopCastR(Value val, PackagedScriptObjectException e)
300:                    throws PackagedScriptObjectException {
301:                return this .val.bopCastR(val, e);
302:            }
303:
304:            /*=======================================================================*/
305:            /**
306:             * Perform the instanceof operation.
307:             * 
308:             * @param val          the other value
309:             * @return the result
310:             * @throws PackagedScriptObjectException(NoSuchMemberException)
311:             */
312:            public Value bopInstanceOf(Value val)
313:                    throws PackagedScriptObjectException {
314:                return this .val.bopInstanceOf(val);
315:            }
316:
317:            public Value bopInstanceOfR(Value val,
318:                    PackagedScriptObjectException e)
319:                    throws PackagedScriptObjectException {
320:                return this .val.bopInstanceOfR(val, e);
321:            }
322:
323:            /*=======================================================================*/
324:            /**
325:             * Perform the logical OR operation.
326:             * 
327:             * @param val          the other value
328:             * @return the result
329:             * @throws PackagedScriptObjectException(NoSuchMemberException)
330:             */
331:            public Value bopLogicalOr(Value val)
332:                    throws PackagedScriptObjectException {
333:                return this .val.bopLogicalOr(val);
334:            }
335:
336:            public Value bopLogicalOrR(Value val,
337:                    PackagedScriptObjectException e)
338:                    throws PackagedScriptObjectException {
339:                return this .val.bopLogicalOrR(val, e);
340:            }
341:
342:            /*=======================================================================*/
343:            /**
344:             * Perform the logical AND operation.
345:             * 
346:             * @param val          the other value
347:             * @return the result
348:             * @throws PackagedScriptObjectException(NoSuchMemberException)
349:             */
350:            public Value bopLogicalAnd(Value val)
351:                    throws PackagedScriptObjectException {
352:                return this .val.bopLogicalAnd(val);
353:            }
354:
355:            public Value bopLogicalAndR(Value val,
356:                    PackagedScriptObjectException e)
357:                    throws PackagedScriptObjectException {
358:                return this .val.bopLogicalAndR(val, e);
359:            }
360:
361:            /*=======================================================================*/
362:            /**
363:             * Perform the bitwise OR operation.
364:             * 
365:             * @param val          the other value
366:             * @return the result
367:             * @throws PackagedScriptObjectException(NoSuchMemberException)
368:             */
369:            public Value bopBitwiseOr(Value val)
370:                    throws PackagedScriptObjectException {
371:                return this .val.bopBitwiseOr(val);
372:            }
373:
374:            public Value bopBitwiseOrR(Value val,
375:                    PackagedScriptObjectException e)
376:                    throws PackagedScriptObjectException {
377:                return this .val.bopBitwiseOrR(val, e);
378:            }
379:
380:            /*=======================================================================*/
381:            /**
382:             * Perform the bitwise XOR operation.
383:             * 
384:             * @param val          the other value
385:             * @return the result
386:             * @throws PackagedScriptObjectException(NoSuchMemberException)
387:             */
388:            public Value bopBitwiseXor(Value val)
389:                    throws PackagedScriptObjectException {
390:                return this .val.bopBitwiseXor(val);
391:            }
392:
393:            public Value bopBitwiseXorR(Value val,
394:                    PackagedScriptObjectException e)
395:                    throws PackagedScriptObjectException {
396:                return this .val.bopBitwiseXorR(val, e);
397:            }
398:
399:            /*=======================================================================*/
400:            /**
401:             * Perform the bitwise AND operation.
402:             * 
403:             * @param val          the other value
404:             * @return the result
405:             * @throws PackagedScriptObjectException(NoSuchMemberException)
406:             */
407:            public Value bopBitwiseAnd(Value val)
408:                    throws PackagedScriptObjectException {
409:                return this .val.bopBitwiseAnd(val);
410:            }
411:
412:            public Value bopBitwiseAndR(Value val,
413:                    PackagedScriptObjectException e)
414:                    throws PackagedScriptObjectException {
415:                return this .val.bopBitwiseAndR(val, e);
416:            }
417:
418:            /*=======================================================================*/
419:            /**
420:             * Perform the "==" operation.
421:             * 
422:             * @param val          the other value
423:             * @return the result
424:             * @throws PackagedScriptObjectException(NoSuchMemberException)
425:             */
426:            public Value bopEquals(Value val)
427:                    throws PackagedScriptObjectException {
428:                return this .val.bopEquals(val);
429:            }
430:
431:            public Value bopEqualsR(Value val, PackagedScriptObjectException e)
432:                    throws PackagedScriptObjectException {
433:                return this .val.bopEqualsR(val, e);
434:            }
435:
436:            /*=======================================================================*/
437:            /**
438:             * Perform the "!=" operation.
439:             * 
440:             * @param val          the other value
441:             * @return the result
442:             * @throws PackagedScriptObjectException(NoSuchMemberException)
443:             */
444:            public Value bopNotEquals(Value val)
445:                    throws PackagedScriptObjectException {
446:                return this .val.bopNotEquals(val);
447:            }
448:
449:            public Value bopNotEqualsR(Value val,
450:                    PackagedScriptObjectException e)
451:                    throws PackagedScriptObjectException {
452:                return this .val.bopNotEqualsR(val, e);
453:            }
454:
455:            /*=======================================================================*/
456:            /**
457:             * Perform the "<" operation.
458:             * 
459:             * @param val          the other value
460:             * @return the result
461:             * @throws PackagedScriptObjectException(NoSuchMemberException)
462:             */
463:            public Value bopLessThan(Value val)
464:                    throws PackagedScriptObjectException {
465:                return this .val.bopLessThan(val);
466:            }
467:
468:            public Value bopLessThanR(Value val, PackagedScriptObjectException e)
469:                    throws PackagedScriptObjectException {
470:                return this .val.bopLessThanR(val, e);
471:            }
472:
473:            /*=======================================================================*/
474:            /**
475:             * Perform the ">" operation.
476:             * 
477:             * @param val          the other value
478:             * @return the result
479:             * @throws PackagedScriptObjectException(NoSuchMemberException)
480:             */
481:            public Value bopGreaterThan(Value val)
482:                    throws PackagedScriptObjectException {
483:                return this .val.bopGreaterThan(val);
484:            }
485:
486:            public Value bopGreaterThanR(Value val,
487:                    PackagedScriptObjectException e)
488:                    throws PackagedScriptObjectException {
489:                return this .val.bopGreaterThanR(val, e);
490:            }
491:
492:            /*=======================================================================*/
493:            /**
494:             * Perform the "<=" operation.
495:             * 
496:             * @param val          the other value
497:             * @return the result
498:             * @throws PackagedScriptObjectException(NoSuchMemberException)
499:             */
500:            public Value bopLessThanOrEquals(Value val)
501:                    throws PackagedScriptObjectException {
502:                return this .val.bopLessThanOrEquals(val);
503:            }
504:
505:            public Value bopLessThanOrEqualsR(Value val,
506:                    PackagedScriptObjectException e)
507:                    throws PackagedScriptObjectException {
508:                return this .val.bopLessThanOrEqualsR(val, e);
509:            }
510:
511:            /*=======================================================================*/
512:            /**
513:             * Perform the ">=" operation.
514:             * 
515:             * @param val          the other value
516:             * @return the result
517:             * @throws PackagedScriptObjectException(NoSuchMemberException)
518:             */
519:            public Value bopGreaterThanOrEquals(Value val)
520:                    throws PackagedScriptObjectException {
521:                return this .val.bopGreaterThanOrEquals(val);
522:            }
523:
524:            public Value bopGreaterThanOrEqualsR(Value val,
525:                    PackagedScriptObjectException e)
526:                    throws PackagedScriptObjectException {
527:                return this .val.bopGreaterThanOrEqualsR(val, e);
528:            }
529:
530:            /*=======================================================================*/
531:            /**
532:             * Perform the "<<" operation.
533:             * 
534:             * @param val          the other value
535:             * @return the result
536:             * @throws PackagedScriptObjectException(NoSuchMemberException)
537:             */
538:            public Value bopLeftShift(Value val)
539:                    throws PackagedScriptObjectException {
540:                return this .val.bopLeftShift(val);
541:            }
542:
543:            public Value bopLeftShiftR(Value val,
544:                    PackagedScriptObjectException e)
545:                    throws PackagedScriptObjectException {
546:                return this .val.bopLeftShiftR(val, e);
547:            }
548:
549:            /*=======================================================================*/
550:            /**
551:             * Perform the ">>" operation.
552:             * 
553:             * @param val          the other value
554:             * @return the result
555:             * @throws PackagedScriptObjectException(NoSuchMemberException)
556:             */
557:            public Value bopSignedRightShift(Value val)
558:                    throws PackagedScriptObjectException {
559:                return this .val.bopSignedRightShift(val);
560:            }
561:
562:            public Value bopSignedRightShiftR(Value val,
563:                    PackagedScriptObjectException e)
564:                    throws PackagedScriptObjectException {
565:                return this .val.bopSignedRightShiftR(val, e);
566:            }
567:
568:            /*=======================================================================*/
569:            /**
570:             * Perform the ">>>" operation.
571:             * 
572:             * @param val          the other value
573:             * @return the result
574:             * @throws PackagedScriptObjectException(NoSuchMemberException)
575:             */
576:            public Value bopUnsignedRightShift(Value val)
577:                    throws PackagedScriptObjectException {
578:                return this .val.bopUnsignedRightShift(val);
579:            }
580:
581:            public Value bopUnsignedRightShiftR(Value val,
582:                    PackagedScriptObjectException e)
583:                    throws PackagedScriptObjectException {
584:                return this .val.bopUnsignedRightShiftR(val, e);
585:            }
586:
587:            /*=======================================================================*/
588:            /**
589:             * Perform the "+" operation.
590:             * 
591:             * @param val          the other value
592:             * @return the result
593:             * @throws PackagedScriptObjectException(NoSuchMemberException)
594:             */
595:            public Value bopPlus(Value val)
596:                    throws PackagedScriptObjectException {
597:                return this .val.bopPlus(val);
598:            }
599:
600:            public Value bopPlusR(Value val, PackagedScriptObjectException e)
601:                    throws PackagedScriptObjectException {
602:                return this .val.bopPlusR(val, e);
603:            }
604:
605:            /*=======================================================================*/
606:            /**
607:             * Perform the "-" operation.
608:             * 
609:             * @param val          the other value
610:             * @return the result
611:             * @throws PackagedScriptObjectException(NoSuchMemberException)
612:             */
613:            public Value bopMinus(Value val)
614:                    throws PackagedScriptObjectException {
615:                return this .val.bopMinus(val);
616:            }
617:
618:            public Value bopMinusR(Value val, PackagedScriptObjectException e)
619:                    throws PackagedScriptObjectException {
620:                return this .val.bopMinusR(val, e);
621:            }
622:
623:            /*=======================================================================*/
624:            /**
625:             * Perform the "*" operation.
626:             * 
627:             * @param val          the other value
628:             * @return the result
629:             * @throws PackagedScriptObjectException(NoSuchMemberException)
630:             */
631:            public Value bopMultiply(Value val)
632:                    throws PackagedScriptObjectException {
633:                return this .val.bopMultiply(val);
634:            }
635:
636:            public Value bopMultiplyR(Value val, PackagedScriptObjectException e)
637:                    throws PackagedScriptObjectException {
638:                return this .val.bopMultiplyR(val, e);
639:            }
640:
641:            /*=======================================================================*/
642:            /**
643:             * Perform the "/" operation.
644:             * 
645:             * @param val          the other value
646:             * @return the result
647:             * @throws PackagedScriptObjectException(NoSuchMemberException)
648:             */
649:            public Value bopDivide(Value val)
650:                    throws PackagedScriptObjectException {
651:                return this .val.bopDivide(val);
652:            }
653:
654:            public Value bopDivideR(Value val, PackagedScriptObjectException e)
655:                    throws PackagedScriptObjectException {
656:                return this .val.bopDivideR(val, e);
657:            }
658:
659:            /*=======================================================================*/
660:            /**
661:             * Perform the "%" operation.
662:             * 
663:             * @param val          the other value
664:             * @return the result
665:             * @throws PackagedScriptObjectException(NoSuchMemberException)
666:             */
667:            public Value bopRemainder(Value val)
668:                    throws PackagedScriptObjectException {
669:                return this .val.bopRemainder(val);
670:            }
671:
672:            public Value bopRemainderR(Value val,
673:                    PackagedScriptObjectException e)
674:                    throws PackagedScriptObjectException {
675:                return this .val.bopRemainderR(val, e);
676:            }
677:
678:            /*=======================================================================*/
679:            /* The unary operators:
680:             */
681:
682:            /*=======================================================================*/
683:            /**
684:             * Perform the "++" operation.
685:             * 
686:             * @param val          the other value
687:             * @return the result
688:             * @throws PackagedScriptObjectException(NoSuchMemberException)
689:             */
690:            public Value uopIncrement() throws PackagedScriptObjectException {
691:                return val.uopIncrement();
692:            }
693:
694:            /*=======================================================================*/
695:            /**
696:             * Perform the "--" operation.
697:             * 
698:             * @param val          the other value
699:             * @return the result
700:             * @throws PackagedScriptObjectException(NoSuchMemberException)
701:             */
702:            public Value uopDecrement() throws PackagedScriptObjectException {
703:                return val.uopDecrement();
704:            }
705:
706:            /*=======================================================================*/
707:            /**
708:             * Perform the "+" operation.
709:             * 
710:             * @param val          the other value
711:             * @return the result
712:             * @throws PackagedScriptObjectException(NoSuchMemberException)
713:             */
714:            public Value uopPlus() throws PackagedScriptObjectException {
715:                return val.uopPlus();
716:            }
717:
718:            /*=======================================================================*/
719:            /**
720:             * Perform the "-" operation.
721:             * 
722:             * @param val          the other value
723:             * @return the result
724:             * @throws PackagedScriptObjectException(NoSuchMemberException)
725:             */
726:            public Value uopMinus() throws PackagedScriptObjectException {
727:                return val.uopMinus();
728:            }
729:
730:            /*=======================================================================*/
731:            /**
732:             * Perform the "~" operation.
733:             * 
734:             * @param val          the other value
735:             * @return the result
736:             * @throws PackagedScriptObjectException(NoSuchMemberException)
737:             */
738:            public Value uopBitwiseNot() throws PackagedScriptObjectException {
739:                return val.uopBitwiseNot();
740:            }
741:
742:            /*=======================================================================*/
743:            /**
744:             * Perform the "!" operation.
745:             * 
746:             * @param val          the other value
747:             * @return the result
748:             * @throws PackagedScriptObjectException(NoSuchMemberException)
749:             */
750:            public Value uopLogicalNot() throws PackagedScriptObjectException {
751:                return val.uopLogicalNot();
752:            }
753:
754:            /*=======================================================================*/
755:            /* The misc operators:
756:             */
757:
758:            /*=======================================================================*/
759:            /**
760:             * Perform assignment.  Set the value of this reference to the specified
761:             * value.
762:             * 
763:             * @param val          the value to set this reference to
764:             * @throws PackagedScriptObjectException(NoSuchMemberException)
765:             */
766:            public void opAssign(Value val)
767:                    throws PackagedScriptObjectException {
768:                // we can't have a reference to a reference:
769:                if (val instanceof  Reference)
770:                    val = val.unhand();
771:
772:                if (val == UNDEFINED) {
773:                    if (!"warning".equals(System
774:                            .getProperty("oscript.undefined.assign")))
775:                        throw PackagedScriptObjectException
776:                                .makeExceptionWrapper(new OUnsupportedOperationException(
777:                                        "cannot assign (undefined) to variable"));
778:
779:                    String desc = "";
780:
781:                    //////////////////////////////////////////////////////////////////////////
782:                    // the following code is a hack to attempt to determine what script called
783:                    // this, so we can print a more informative warning message:
784:                    try {
785:                        oscript.util.StackFrame sf = oscript.util.StackFrame
786:                                .currentStackFrame();
787:                        desc = " at " + sf.toString();
788:                    } catch (Throwable t) {
789:                        // ignore... an exception may be thrown if not called from script 
790:                    }
791:                    //////////////////////////////////////////////////////////////////////////
792:                    oscript.util.ErrorHandler
793:                            .warning("warning: cannot assign (undefined) to variable"
794:                                    + desc);
795:                }
796:
797:                // in the case of "const" values, they can be assigned a value
798:                // only once:
799:                if ((attr & ATTR_CONST) != 0) {
800:                    if (readonly)
801:                        throw PackagedScriptObjectException
802:                                .makeExceptionWrapper(new OUnsupportedOperationException(
803:                                        "cannot assign value to constant"));
804:                    else
805:                        readonly = true;
806:                }
807:
808:                this .val = val;
809:            }
810:
811:            /*=======================================================================*/
812:            /**
813:             * Call this object as a function.
814:             * 
815:             * @param sf           the current stack frame
816:             * @param args         the arguments to the function
817:             * @return the value returned by the function
818:             * @throws PackagedScriptObjectException
819:             * @see Function
820:             */
821:            public Value callAsFunction(StackFrame sf, MemberTable args)
822:                    throws PackagedScriptObjectException {
823:                return val.callAsFunction(sf, args);
824:            }
825:
826:            /*=======================================================================*/
827:            /**
828:             * Call this object as a constructor.
829:             * 
830:             * @param sf           the current stack frame
831:             * @param args         the arguments to the function
832:             * @return the newly constructed object
833:             * @throws PackagedScriptObjectException
834:             * @see Function
835:             */
836:            public Value callAsConstructor(StackFrame sf, MemberTable args)
837:                    throws PackagedScriptObjectException {
838:                return val.callAsConstructor(sf, args);
839:            }
840:
841:            /*=======================================================================*/
842:            /**
843:             * Call this object as a parent class constructor.
844:             * 
845:             * @param sf           the current stack frame
846:             * @param scope        the object
847:             * @param args         the arguments to the function
848:             * @return the value returned by the function
849:             * @throws PackagedScriptObjectException
850:             * @see Function
851:             */
852:            public Value callAsExtends(StackFrame sf, Scope scope,
853:                    MemberTable args) throws PackagedScriptObjectException {
854:                return val.callAsExtends(sf, scope, args);
855:            }
856:
857:            /*=======================================================================*/
858:            /**
859:             * Get a member of this object.
860:             * 
861:             * @param id           the id of the symbol that maps to the member
862:             * @param exception    whether an exception should be thrown if the
863:             *   member object is not resolved
864:             * @return a reference to the member
865:             * @throws PackagedScriptObjectException(NoSuchMethodException)
866:             * @throws PackagedScriptObjectException(NoSuchMemberException)
867:             */
868:            public Value getMember(int id, boolean exception)
869:                    throws PackagedScriptObjectException {
870:                return val.getMember(id, exception);
871:            }
872:
873:            /*=======================================================================*/
874:            /**
875:             * Get a member of this type.  This is used to interface to the java
876:             * method of having members be attributes of a type.  Regular object-
877:             * script object's members are attributes of the object, but in the
878:             * case of java types (including built-in types), the members are
879:             * attributes of the type.
880:             * 
881:             * @param obj          an object of this type
882:             * @param id           the id of the symbol that maps to the member
883:             * @return a reference to the member, or null
884:             */
885:            protected Value getTypeMember(Value obj, int id) {
886:                return val.getTypeMember(obj, id);
887:            }
888:
889:            /*=======================================================================*/
890:            /**
891:             * For types that implement <code>elementAt</code>, this returns the
892:             * number of elements.
893:             * 
894:             * @return an integer length
895:             * @throws PackagedScriptObjectException(NoSuchMemberException)
896:             * @see #elementAt
897:             * @see #elementsAt
898:             */
899:            public int length() throws PackagedScriptObjectException {
900:                return val.length();
901:            }
902:
903:            /*=======================================================================*/
904:            /**
905:             * Get the specified index of this object, if this object is an array.  If
906:             * needed, the array is grown to the appropriate size.
907:             * 
908:             * @param idx          the index to get
909:             * @return a reference to the member
910:             * @throws PackagedScriptObjectException(NoSuchMemberException)
911:             * @see #length
912:             * @see #elementsAt
913:             */
914:            public Value elementAt(Value idx)
915:                    throws PackagedScriptObjectException {
916:                return val.elementAt(idx);
917:            }
918:
919:            /*=======================================================================*/
920:            /**
921:             * Get the specified range of this object, if this object is an array.  
922:             * This returns a copy of a range of the array.
923:             * 
924:             * @param idx1         the index index of the beginning of the range, inclusive
925:             * @param idx2         the index of the end of the range, inclusive
926:             * @return a copy of the specified range of this array
927:             * @throws PackagedScriptObjectException(NoSuchMemberException)
928:             * @see #length
929:             * @see #elementAt
930:             */
931:            public Value elementsAt(Value idx1, Value idx2)
932:                    throws PackagedScriptObjectException {
933:                return val.elementsAt(idx1, idx2);
934:            }
935:
936:            /*=======================================================================*/
937:            /**
938:             * Returns the names of the members of this object.
939:             * 
940:             * @return a collection view of the names of the members of this object
941:             */
942:            public final java.util.Set memberSet() {
943:                return val.memberSet();
944:            }
945:        }
946:
947:        /*
948:         *   Local Variables:
949:         *   tab-width: 2
950:         *   indent-tabs-mode: nil
951:         *   mode: java
952:         *   c-indentation-style: java
953:         *   c-basic-offset: 2
954:         *   eval: (c-set-offset 'substatement-open '0)
955:         *   eval: (c-set-offset 'case-label '+)
956:         *   eval: (c-set-offset 'inclass '+)
957:         *   eval: (c-set-offset 'inline-open '0)
958:         *   End:
959:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.