Gets a scope model
<p/>
Adds the model if it is not present.

@param <T>   The type
@param scope The scope type
@return The scope type model
2261
public <T extends Annotation> ScopeModel<T> getScopeModel(final Class<T> scope) {
        return scopes.getCastValue(scope);
    }
312393
public static Object getScopedRequestAttribute( String attrName, ServletRequest request )
    {
        if ( request instanceof ScopedRequest )
        {
            return ( ( ScopedRequest ) request ).getAttribute( attrName, false );
        }
        
        return request.getAttribute( attrName );
    }
276281
protected static Object getScopeService(IScope scope, String name) {
        return getScopeService(scope, name, null);
    }
1133221
public boolean hasChildScope(ScopeType type, String name) {
        log.debug("Has child scope? {} in {}", name, this);
        return children.getBasicScope(type, name) != null;
    }
1295618
public static void addToScope(Scriptable scope, InputRow inputRow, InputColumn<?>[] columns, String arrayName) {
		NativeArray values = new NativeArray(columns.length * 2);
		for (int i = 0; i < columns.length; i++) {
			InputColumn<?> column = columns[i];
			Object value = inputRow.getValue(column);

			if (value != null) {
				Class<?> dataType = column.getDataType();
				if (ReflectionUtils.isNumber(dataType)) {
					value = Context.toNumber(value);
				} else if (ReflectionUtils.isBoolean(dataType)) {
					value = Context.toBoolean(value);
				}
			}

			values.put(i, values, value);
			values.put(column.getName(), values, value);

			addToScope(scope, value, column.getName(), column.getName().toLowerCase(), column.getName().toUpperCase());
		}

		addToScope(scope, values, arrayName);
	}
977253
public Scriptable newObject(Scriptable scope)
    {
        NativeObject result = new NativeObject();
        ScriptRuntime.setBuiltinProtoAndParent(result, scope,
                TopLevel.Builtins.Object);
        return result;
    }
1151240
public void addScope(CmsGallerySearchScope scope) {

        m_searchObject.setScope(scope);
        m_searchObjectChanged = true;
        ValueChangeEvent.fire(this, m_searchObject);
    }
1137653
protected static Object getScopeService(IScope scope, String name, Class<?> defaultClass) {
        if (scope != null) {
            final IContext context = scope.getContext();
            ApplicationContext appCtx = context.getApplicationContext();
            Object result;
            if (!appCtx.containsBean(name)) {
                if (defaultClass == null) {
                    return null;
                }
                try {
                    result = defaultClass.newInstance();
                } catch (Exception e) {
                    log.error("{}", e);
                    return null;
                }
            } else {
                result = appCtx.getBean(name);
            }
            return result;
        }
        return null;
    }
99945
public Observable<ServiceResponse<ManagementLockObjectInner>> getByScopeWithServiceResponseAsync(String scope, String lockName) {
        if (scope == null) {
            throw new IllegalArgumentException("Parameter scope is required and cannot be null.");
        }
        if (lockName == null) {
            throw new IllegalArgumentException("Parameter lockName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.getByScope(scope, lockName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ManagementLockObjectInner>>>() {
                @Override
                public Observable<ServiceResponse<ManagementLockObjectInner>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<ManagementLockObjectInner> clientResponse = getByScopeDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }
743655
private Stream<Type> scopeTypes(GraqlCompute query) {
        // Get all types if query.inTypes() is empty, else get all scoped types of each meta type.
        // Only include attributes and implicit "has-xxx" relations when user specifically asked for them.
        if (query.in().isEmpty()) {
            ImmutableSet.Builder<Type> typeBuilder = ImmutableSet.builder();

            if (scopeIncludesAttributes(query)) {
                tx.getMetaConcept().subs().forEach(typeBuilder::add);
            } else {
                tx.getMetaEntityType().subs().forEach(typeBuilder::add);
                tx.getMetaRelationType().subs()
                        .filter(relationType -> !relationType.isImplicit()).forEach(typeBuilder::add);
            }

            return typeBuilder.build().stream();
        } else {
            Stream<Type> subTypes = query.in().stream().map(t -> {
                Label label = Label.of(t);
                Type type = tx.getType(label);
                if (type == null) throw GraqlQueryException.labelNotFound(label);
                return type;
            }).flatMap(Type::subs);

            if (!scopeIncludesAttributes(query)) {
                subTypes = subTypes.filter(relationType -> !relationType.isImplicit());
            }

            return subTypes;
        }
    }
492645
public int get_searchScope() {
        int searchScope = SearchControls.OBJECT_SCOPE;
        String scopeBuf = get_scope();
        if (scopeBuf != null) {
            if (scopeBuf.compareToIgnoreCase("base") == 0) {
                searchScope = SearchControls.OBJECT_SCOPE;
            } else if (scopeBuf.compareToIgnoreCase("one") == 0) {
                searchScope = SearchControls.ONELEVEL_SCOPE;
            } else if (scopeBuf.compareToIgnoreCase("sub") == 0) {
                searchScope = SearchControls.SUBTREE_SCOPE;
            }
        }
        return searchScope;
    }
970003
public Object eval(Scope scope) {
		Object value = expr.eval(scope);
		if (value == null) {
			if (scope.getCtrl().isNullSafe()) {
				return null;
			}
			throw new TemplateException("The parameter of \"" + op.value() + "\" operator can not be blank", location);
		}
		if (! (value instanceof Number) ) {
			throw new TemplateException(op.value() + " operator only support int long float double BigDecimal type", location);
		}
		
		switch (op) {
		case ADD:
			return value;
		case SUB:
			Number n = (Number)value;
			if (n instanceof Integer) {
                return Integer.valueOf(-n.intValue());
            }
			if (n instanceof Long) {
                return Long.valueOf(-n.longValue());
            }
			if (n instanceof Float) {
                return Float.valueOf(-n.floatValue());
            }
			if (n instanceof Double) {
                return Double.valueOf(-n.doubleValue());
            }
			if (n instanceof BigDecimal) {
            	return ((BigDecimal)n).negate();
			}
            throw new TemplateException("Unsupported data type: " + n.getClass().getName(), location);
		default :
			throw new TemplateException("Unsupported operator: " + op.value(), location);
		}
	}
977755
public CompletableFuture<String> getScope(final String scopeName) {
        Preconditions.checkNotNull(scopeName);
        return streamStore.getScopeConfiguration(scopeName);
    }
190539
public void setScope(String scope) {
        if (scope.equalsIgnoreCase("page")) {
            this.scope = PageContext.PAGE_SCOPE;
        } else if (scope.equalsIgnoreCase("request")) {
            this.scope = PageContext.REQUEST_SCOPE;
        } else if (scope.equalsIgnoreCase("session")) {
            this.scope = PageContext.SESSION_SCOPE;
        } else if (scope.equalsIgnoreCase("application")) {
            this.scope = PageContext.APPLICATION_SCOPE;
        }
        // TODO: Add error handling?  Needs direction from spec.
    }
119305
static <T> Binding<T> scope(final Binding<T> binding) {
    if (!binding.isSingleton() || binding instanceof SingletonBinding) {
      return binding; // Default scoped binding or already a scoped binding.
    }
    return new SingletonBinding<T>(binding);
  }
1154262
public void setScope(String scope) {
        SystemAssert.requireArgument(scope != null && !scope.isEmpty(), "Scope cannot be null or empty.");
        this.scope = scope;
    }
192125
@Nullable
    public <T> Class<Provider<T>> getScopedFactoryClass(Class scope, Class<T> classDefinition) {
        //noinspection unchecked
        return (Class)factoryClasses.getScope(scope).get(classDefinition);
    }