001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.quercus.resources;
031:
032: import com.caucho.quercus.env.*;
033:
034: /**
035: * Represents a PHP stream context.
036: */
037: public class StreamContextResource extends ResourceValue {
038: private ArrayValue _options;
039: private ArrayValue _parameters;
040:
041: public StreamContextResource() {
042: this (null);
043: }
044:
045: public StreamContextResource(ArrayValue options) {
046: this (options, null);
047: }
048:
049: public StreamContextResource(ArrayValue options,
050: ArrayValue parameters) {
051: if (options == null)
052: options = new ArrayValueImpl();
053:
054: if (parameters == null)
055: parameters = new ArrayValueImpl();
056:
057: _options = options;
058: _parameters = parameters;
059: }
060:
061: /**
062: * Returns the options.
063: */
064: public ArrayValue getOptions() {
065: return _options;
066: }
067:
068: /**
069: * Sets the options.
070: */
071: public void setOptions(ArrayValue options) {
072: _options = options;
073: }
074:
075: /**
076: * Sets an option
077: */
078: public void setOption(String wrapper, String option, Value value) {
079: // XXX: i18n
080: StringValue wrapperV = new StringBuilderValue(wrapper);
081: StringValue optionV = new StringBuilderValue(option);
082:
083: _options.getArray(wrapperV).put(optionV, value);
084: }
085:
086: /**
087: * Sets the parameters.
088: */
089: public void setParameters(ArrayValue parameters) {
090: _parameters = parameters;
091: }
092:
093: /**
094: * Converts to a string.
095: * @param env
096: */
097: public StringValue toString(Env env) {
098: return env.createString("StreamContextResource[]");
099: }
100: }
|