001: /*
002: * $Id: AbstractCAPICallResult.java,v 1.22 2007/05/15 11:33:19 agoubard Exp $
003: *
004: * Copyright 2003-2007 Orange Nederland Breedband B.V.
005: * See the COPYRIGHT file for redistribution and use restrictions.
006: */
007: package org.xins.client;
008:
009: import java.io.Serializable;
010:
011: import org.xins.common.MandatoryArgumentChecker;
012: import org.xins.common.service.CallExceptionList;
013: import org.xins.common.service.TargetDescriptor;
014:
015: /**
016: * Base class for generated CAPI function result classes.
017: *
018: * <p>This class should not be subclassed manually. It is only intended to be
019: * subclassed by classes generated by XINS.
020: *
021: * @version $Revision: 1.22 $ $Date: 2007/05/15 11:33:19 $
022: * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
023: *
024: * @since XINS 1.0.0
025: */
026: public abstract class AbstractCAPICallResult implements Serializable {
027:
028: /**
029: * The XINS call result. This field cannot be <code>null</code>.
030: */
031: private XINSCallResult _result;
032:
033: /**
034: * Creates a new <code>AbstractCAPICallResult</code> object, based on the
035: * specified <code>XINSCallResult</code>.
036: *
037: * @param result
038: * the lower-level {@link XINSCallResult}, cannot be <code>null</code>.
039: *
040: * @throws IllegalArgumentException
041: * if <code>result == null</code>.
042: */
043: protected AbstractCAPICallResult(XINSCallResult result)
044: throws IllegalArgumentException {
045:
046: // Check preconditions
047: MandatoryArgumentChecker.check("result", result);
048:
049: // Store field
050: _result = result;
051:
052: // Check preconditions
053: if (result.getErrorCode() != null) {
054: throw new IllegalArgumentException(
055: "result.getErrorCode() != null");
056: }
057: }
058:
059: /**
060: * Returns the underlying XINS call result.
061: *
062: * @return
063: * the underlying {@link XINSCallResult} object, never
064: * <code>null</code>.
065: */
066: XINSCallResult getXINSCallResult() {
067: return _result;
068: }
069:
070: /**
071: * Returns the target for which the call succeeded.
072: *
073: * @return
074: * the {@link TargetDescriptor} for which the call succeeded, not
075: * <code>null</code>.
076: *
077: * @since XINS 1.1.0
078: */
079: public final TargetDescriptor succeededTarget() {
080: return _result.getSucceededTarget();
081: }
082:
083: /**
084: * Returns the call duration, in milliseconds.
085: *
086: * @return
087: * the duration of the succeeded call, in milliseconds, guaranteed to
088: * be a non-negative number.
089: *
090: * @since XINS 1.1.0
091: */
092: public final long duration() {
093: return _result.getDuration();
094: }
095:
096: /**
097: * Returns the list of <code>CallException</code>s.
098: *
099: * @return
100: * the {@link org.xins.common.service.CallException}s,
101: * collected in a {@link CallExceptionList} object,
102: * or <code>null</code> if the first call attempt succeeded.
103: *
104: * @since XINS 1.1.0
105: */
106: public final CallExceptionList exceptions() {
107: return _result.getExceptions();
108: }
109: }
|