Coverage Report - org.vostokframework.domain.loading.states.fileloader.adapters.DataLoaderAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
DataLoaderAdapter
69%
27/39
N/A
0
 
 1  
 /*
 2  
  * Licensed under the MIT License
 3  
  * 
 4  
  * Copyright 2011 (c) Flávio Silva, flsilva.com
 5  
  *
 6  
  * Permission is hereby granted, free of charge, to any person
 7  
  * obtaining a copy of this software and associated documentation
 8  
  * files (the "Software"), to deal in the Software without
 9  
  * restriction, including without limitation the rights to use,
 10  
  * copy, modify, merge, publish, distribute, sublicense, and/or sell
 11  
  * copies of the Software, and to permit persons to whom the
 12  
  * Software is furnished to do so, subject to the following
 13  
  * conditions:
 14  
  *
 15  
  * The above copyright notice and this permission notice shall be
 16  
  * included in all copies or substantial portions of the Software.
 17  
  *
 18  
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 19  
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 20  
  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 21  
  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22  
  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 23  
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 24  
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 25  
  * OTHER DEALINGS IN THE SOFTWARE.
 26  
  * 
 27  
  * http://www.opensource.org/licenses/mit-license.php
 28  
  */
 29  1
 package org.vostokframework.domain.loading.states.fileloader.adapters
 30  
 {
 31  
         import org.as3coreaddendum.errors.ObjectDisposedError;
 32  
         import org.as3coreaddendum.errors.UnsupportedOperationError;
 33  
         import org.as3utils.ReflectionUtil;
 34  
         import org.vostokframework.domain.loading.states.fileloader.IDataLoader;
 35  
 
 36  
         import flash.errors.IllegalOperationError;
 37  
         import flash.events.Event;
 38  
         import flash.events.IEventDispatcher;
 39  
 
 40  
         /**
 41  
          * description
 42  
          * 
 43  
          * @author Flávio Silva
 44  
          */
 45  
         public class DataLoaderAdapter implements IDataLoader
 46  
         {
 47  
                 /**
 48  
                  * @private
 49  
                   */
 50  
                 private var _disposed:Boolean;
 51  
                 
 52  
                 /**
 53  
                  * description
 54  
                  * 
 55  
                  * @param loader
 56  
                  * @param request
 57  
                  * @param context
 58  
                  */
 59  
                 public function DataLoaderAdapter()
 60  1
                 {
 61  1
                         if (ReflectionUtil.classPathEquals(this, DataLoaderAdapter))  throw new IllegalOperationError(ReflectionUtil.getClassName(this) + " is an abstract class and shouldn't be directly instantiated.");
 62  1
                 }
 63  
                 
 64  
                 public function addEventListener(type : String, listener : Function, useCapture : Boolean = false, priority : int = 0, useWeakReference : Boolean = false) : void
 65  
                 {
 66  1
                         validateDisposal();
 67  1
                         getLoadingDispatcher().addEventListener(type, listener, useCapture, priority, useWeakReference);
 68  1
                 }
 69  
                 
 70  
                 public function cancel():void
 71  
                 {
 72  1
                         validateDisposal();
 73  1
                         doCancel();
 74  1
                 }
 75  
                 
 76  
                 public function dispatchEvent(event: Event): Boolean
 77  
                 {
 78  0
                         validateDisposal();
 79  0
                         return getLoadingDispatcher().dispatchEvent(event);
 80  
                 }
 81  
                 
 82  
                 public function dispose():void
 83  
                 {
 84  1
                         if (_disposed) return;
 85  
                         
 86  1
                         doDispose();
 87  
                         
 88  1
                         _disposed = true;
 89  1
                 }
 90  
                 
 91  
                 public function getData():*
 92  
                 {
 93  1
                         validateDisposal();
 94  1
                         return doGetData();
 95  
                 }
 96  
                 
 97  
                 public function hasEventListener(type: String): Boolean
 98  
                 {
 99  0
                         validateDisposal();
 100  0
                         return getLoadingDispatcher().hasEventListener(type);
 101  
                 }
 102  
                 
 103  
                 public function load():void
 104  
                 {
 105  1
                         validateDisposal();
 106  1
                         doLoad();
 107  1
                 }
 108  
                 
 109  
                 public function removeEventListener(type : String, listener : Function, useCapture : Boolean = false) : void
 110  
                 {
 111  1
                         validateDisposal();
 112  1
                         getLoadingDispatcher().removeEventListener(type, listener, useCapture);
 113  1
                 }
 114  
                 
 115  
                 public function stop():void
 116  
                 {
 117  1
                         validateDisposal();
 118  1
                         doStop();
 119  1
                 }
 120  
                 
 121  
                 public function willTrigger(type: String): Boolean
 122  
                 {
 123  0
                         validateDisposal();
 124  0
                         return getLoadingDispatcher().willTrigger(type);
 125  
                 }
 126  
                 
 127  
                 /**
 128  
                  * description
 129  
                  */
 130  
                 protected function doCancel(): void
 131  
                 {
 132  0
                         throw new UnsupportedOperationError("Method must be overridden in subclass: " + ReflectionUtil.getClassPath(this));
 133  
                 }
 134  
                 
 135  
                 protected function doDispose():void
 136  
                 {
 137  0
                         throw new UnsupportedOperationError("Method must be overridden in subclass: " + ReflectionUtil.getClassPath(this));
 138  
                 }
 139  
                 
 140  
                 protected function doGetData():*
 141  
                 {
 142  0
                         throw new UnsupportedOperationError("Method must be overridden in subclass: " + ReflectionUtil.getClassPath(this));
 143  
                 }
 144  
                 
 145  
                 /**
 146  
                  * description
 147  
                  */
 148  
                 protected function doLoad(): void
 149  
                 {
 150  0
                         throw new UnsupportedOperationError("Method must be overridden in subclass: " + ReflectionUtil.getClassPath(this));
 151  
                 }
 152  
                 
 153  
                 /**
 154  
                  * description
 155  
                  */
 156  
                 protected function doStop():void
 157  
                 {
 158  0
                         throw new UnsupportedOperationError("Method must be overridden in subclass: " + ReflectionUtil.getClassPath(this));
 159  
                 }
 160  
                 
 161  
                 protected function getLoadingDispatcher():IEventDispatcher
 162  
                 {
 163  0
                         throw new UnsupportedOperationError("Method must be overridden in subclass: " + ReflectionUtil.getClassPath(this));
 164  
                 }
 165  
                 
 166  
                 /**
 167  
                  * @private
 168  
                  */
 169  
                 private function validateDisposal():void
 170  
                 {
 171  1
                         if (_disposed) throw new ObjectDisposedError("This object was disposed, therefore no more operations can be performed.");
 172  1
                 }
 173  
 
 174  
         }
 175  
 
 176  
 }