index int64 0 0 | repo_id stringlengths 9 205 | file_path stringlengths 31 246 | content stringlengths 1 12.2M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlElementRef.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.FIELD, ElementType.METHOD})
public @interface XmlElementRef {
final class DEFAULT {
}
String name() default "##default";
String namespace() default "";
Class type() default DEFAULT.class;
}
| 1,200 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/W3CDomHandler.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.Source;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.bind.ValidationEventHandler;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.DocumentFragment;
public class W3CDomHandler implements DomHandler<Element, DOMResult> {
private DocumentBuilder builder;
public W3CDomHandler() {
}
public W3CDomHandler(DocumentBuilder builder) {
if (builder == null) {
throw new IllegalArgumentException();
}
this.builder = builder;
}
public DOMResult createUnmarshaller(ValidationEventHandler errorHandler) {
if (builder == null) {
return new DOMResult();
} else {
return new DOMResult(builder.newDocument());
}
}
public DocumentBuilder getBuilder() {
return builder;
}
public Element getElement(DOMResult rt) {
Node n = rt.getNode();
if (n instanceof Document) {
return ((Document)n).getDocumentElement();
}
if (n instanceof Element) {
return (Element)n;
}
if (n instanceof DocumentFragment) {
return (Element)n.getChildNodes().item(0);
} else {
throw new IllegalStateException(n.toString());
}
}
public Source marshal(Element n, ValidationEventHandler errorHandler) {
return new DOMSource(n);
}
public void setBuilder(DocumentBuilder builder) {
this.builder = builder;
}
}
| 1,201 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlSeeAlso.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface XmlSeeAlso {
Class[] value();
}
| 1,202 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlAnyAttribute.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.FIELD, ElementType.METHOD })
public @interface XmlAnyAttribute {
}
| 1,203 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlRootElement.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface XmlRootElement {
String name() default "##default";
String namespace() default "##default";
}
| 1,204 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlAccessType.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
public enum XmlAccessType {
FIELD,
NONE,
PROPERTY,
PUBLIC_MEMBER
}
| 1,205 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlEnumValue.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface XmlEnumValue {
String value();
}
| 1,206 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlEnum.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface XmlEnum {
Class<?> value() default String.class;
}
| 1,207 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlValue.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.FIELD, ElementType.METHOD})
public @interface XmlValue {
}
| 1,208 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/XmlElementRefs.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.FIELD, ElementType.METHOD})
public @interface XmlElementRefs {
XmlElementRef[] value();
}
| 1,209 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/adapters/XmlAdapter.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation.adapters;
public abstract class XmlAdapter<ValueType, BoundType> {
protected XmlAdapter() {
}
public abstract ValueType marshal(BoundType v) throws Exception;
public abstract BoundType unmarshal(ValueType v) throws Exception;
}
| 1,210 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/adapters/HexBinaryAdapter.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation.adapters;
import javax.xml.bind.DatatypeConverter;
public final class HexBinaryAdapter extends XmlAdapter<String, byte[]> {
public String marshal(byte[] v) {
return DatatypeConverter.printHexBinary(v);
}
public byte[] unmarshal(String v) {
return DatatypeConverter.parseHexBinary(v);
}
}
| 1,211 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation.adapters;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.PACKAGE})
public @interface XmlJavaTypeAdapters {
XmlJavaTypeAdapter[] value();
}
| 1,212 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/adapters/NormalizedStringAdapter.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation.adapters;
public final class NormalizedStringAdapter extends XmlAdapter<String, String> {
public String marshal(String v) {
return v;
}
public String unmarshal(String v) {
if (v == null) {
return null;
}
int i;
for (i = v.length() - 1; i >= 0 && !isWhiteSpaceExceptSpace(v.charAt(i)); i--);
if (i < 0) {
return v;
}
char buf[] = v.toCharArray();
buf[i--] = ' ';
for(; i >= 0; i--) {
if(isWhiteSpaceExceptSpace(buf[i])) {
buf[i] = ' ';
}
}
return new String(buf);
}
protected static boolean isWhiteSpaceExceptSpace(char ch) {
if (ch >= ' ') {
return false;
} else {
return ch == '\t' || ch == '\n' || ch == '\r';
}
}
}
| 1,213 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation.adapters;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.PACKAGE, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER})
public @interface XmlJavaTypeAdapter {
final class DEFAULT {
}
Class<? extends XmlAdapter> value();
Class type() default DEFAULT.class;
}
| 1,214 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.annotation.adapters;
public class CollapsedStringAdapter extends XmlAdapter<String, String> {
public String marshal(String v) {
return v;
}
public String unmarshal(String v) {
if(v == null) {
return null;
}
int len = v.length();
int s;
for (s = 0; s < len && !isWhiteSpace(v.charAt(s)); s++);
if (s == len) {
return v;
}
StringBuffer result = new StringBuffer(len);
if (s != 0) {
for(int i = 0; i < s; i++) {
result.append(v.charAt(i));
}
result.append(' ');
}
boolean inStripMode = true;
for (int i = s + 1; i < len; i++) {
char ch = v.charAt(i);
boolean b = isWhiteSpace(ch);
if (inStripMode && b) {
continue;
}
inStripMode = b;
result.append(inStripMode ? ' ' : ch);
}
len = result.length();
if (len > 0 && result.charAt(len - 1) == ' ') {
result.setLength(len - 1);
}
return result.toString();
}
protected static boolean isWhiteSpace(char ch) {
if (ch > ' ') {
return false;
} else {
return ch == '\t' || ch == '\n' || ch == '\r' || ch == ' ';
}
}
}
| 1,215 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.helpers;
import java.io.File;
import java.io.InputStream;
import java.io.Reader;
import java.net.URL;
import java.net.MalformedURLException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.bind.UnmarshallerHandler;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.UnmarshalException;
import javax.xml.bind.JAXBException;
import javax.xml.bind.PropertyException;
import javax.xml.bind.attachment.AttachmentUnmarshaller;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.validation.Schema;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.dom.DOMSource;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamReader;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
public abstract class AbstractUnmarshallerImpl implements Unmarshaller {
protected boolean validating;
private ValidationEventHandler eventHandler;
private XMLReader reader;
protected UnmarshalException createUnmarshalException(SAXException e) {
Exception nested = e.getException();
if (nested instanceof UnmarshalException) {
return (UnmarshalException)nested;
} else if(nested instanceof RuntimeException) {
throw (RuntimeException)nested;
} else if (nested != null) {
return new UnmarshalException(nested);
} else {
return new UnmarshalException(e);
}
}
protected XMLReader getXMLReader() throws JAXBException {
if (reader == null) {
try {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
parserFactory.setValidating(false);
reader = parserFactory.newSAXParser().getXMLReader();
} catch(ParserConfigurationException e) {
throw new JAXBException(e);
} catch(SAXException e) {
throw new JAXBException(e);
}
}
return reader;
}
public <A extends XmlAdapter> A getAdapter(Class<A> type) {
throw new UnsupportedOperationException();
}
public AttachmentUnmarshaller getAttachmentUnmarshaller() {
throw new UnsupportedOperationException();
}
public ValidationEventHandler getEventHandler() throws JAXBException {
return eventHandler;
}
public Listener getListener() {
throw new UnsupportedOperationException();
}
public Object getProperty(String name) throws PropertyException {
if(name == null) {
throw new IllegalArgumentException("name must not be null");
}
throw new PropertyException(name);
}
public Schema getSchema() {
throw new UnsupportedOperationException();
}
public boolean isValidating() throws JAXBException {
return validating;
}
public <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter) {
throw new UnsupportedOperationException();
}
public void setAdapter(XmlAdapter adapter) {
if (adapter == null) {
throw new IllegalArgumentException();
}
setAdapter((Class<XmlAdapter>) adapter.getClass(), adapter);
}
public void setAttachmentUnmarshaller(AttachmentUnmarshaller au) {
throw new UnsupportedOperationException();
}
public void setEventHandler(ValidationEventHandler handler) throws JAXBException {
if (handler == null) {
handler = new DefaultValidationEventHandler();
}
eventHandler = handler;
}
public void setListener(Listener listener) {
throw new UnsupportedOperationException();
}
public void setProperty(String name, Object value) throws PropertyException {
if(name == null) {
throw new IllegalArgumentException("name must not be null");
}
throw new PropertyException(name, value);
}
public void setSchema(Schema schema) {
throw new UnsupportedOperationException();
}
public void setValidating(boolean validating) throws JAXBException {
this.validating = validating;
}
public final Object unmarshal(File file) throws JAXBException {
if (file == null) {
throw new IllegalArgumentException("file must not be null");
}
try
{
String path = file.getAbsolutePath();
if (File.separatorChar != '/') {
path = path.replace(File.separatorChar, '/');
}
if (!path.startsWith("/")) {
path = "/" + path;
}
if (!path.endsWith("/") && file.isDirectory()) {
path = path + "/";
}
return unmarshal(new URL("file", "", path));
}
catch(MalformedURLException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
public final Object unmarshal(InputSource source) throws JAXBException {
if (source == null) {
throw new IllegalArgumentException("source must not be null");
}
return unmarshal(getXMLReader(), source);
}
public final Object unmarshal(InputStream is) throws JAXBException {
if (is == null) {
throw new IllegalArgumentException("is must not be null");
}
return unmarshal(new InputSource(is));
}
public <T> JAXBElement<T> unmarshal(Node node, Class<T> declaredType) throws JAXBException {
throw new UnsupportedOperationException();
}
public final Object unmarshal(Reader reader) throws JAXBException {
if (reader == null) {
throw new IllegalArgumentException("reader must not be null");
}
return unmarshal(new InputSource(reader));
}
public Object unmarshal(Source source) throws JAXBException {
if (source == null) {
throw new IllegalArgumentException("source must not be null");
} else if (source instanceof SAXSource) {
SAXSource saxSource = (SAXSource) source;
XMLReader reader = saxSource.getXMLReader();
if (reader == null) {
reader = getXMLReader();
}
return unmarshal(reader, saxSource.getInputSource());
} else if (source instanceof StreamSource) {
StreamSource ss = (StreamSource) source;
InputSource is = new InputSource();
is.setSystemId(ss.getSystemId());
is.setByteStream(ss.getInputStream());
is.setCharacterStream(ss.getReader());
return unmarshal(is);
} else if (source instanceof DOMSource)
return unmarshal(((DOMSource) source).getNode());
else
throw new IllegalArgumentException();
}
protected abstract Object unmarshal(XMLReader xmlreader, InputSource inputsource) throws JAXBException;
public <T> JAXBElement<T> unmarshal(Source source, Class<T> declaredType) throws JAXBException {
throw new UnsupportedOperationException();
}
public final Object unmarshal(URL url) throws JAXBException {
if(url == null) {
throw new IllegalArgumentException("url must not be null");
}
return unmarshal(new InputSource(url.toExternalForm()));
}
public Object unmarshal(XMLEventReader reader) throws JAXBException {
throw new UnsupportedOperationException();
}
public <T> JAXBElement<T> unmarshal(XMLEventReader reader, Class<T> declaredType) throws JAXBException {
throw new UnsupportedOperationException();
}
public Object unmarshal(XMLStreamReader reader) throws JAXBException {
throw new UnsupportedOperationException();
}
public <T> JAXBElement<T> unmarshal(XMLStreamReader reader, Class<T> declaredType) throws JAXBException {
throw new UnsupportedOperationException();
}
}
| 1,216 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/helpers/ValidationEventLocatorImpl.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.helpers;
import java.net.URL;
import java.net.MalformedURLException;
import javax.xml.bind.ValidationEventLocator;
import org.w3c.dom.Node;
import org.xml.sax.SAXParseException;
import org.xml.sax.Locator;
public class ValidationEventLocatorImpl implements ValidationEventLocator {
private URL url;
private int offset = -1;
private int lineNumber = -1;
private int columnNumber = -1;
private Object object;
private Node node;
public ValidationEventLocatorImpl() {
}
public ValidationEventLocatorImpl(Locator loc) {
if (loc == null) {
throw new IllegalArgumentException("loc must not be null");
}
url = toURL(loc.getSystemId());
columnNumber = loc.getColumnNumber();
lineNumber = loc.getLineNumber();
}
public ValidationEventLocatorImpl(SAXParseException e) {
if (e == null) {
throw new IllegalArgumentException("e must not be null");
}
url = toURL(e.getSystemId());
columnNumber = e.getColumnNumber();
lineNumber = e.getLineNumber();
}
public ValidationEventLocatorImpl(Node node) {
if (node == null) {
throw new IllegalArgumentException("node must not be null");
}
this.node = node;
}
public ValidationEventLocatorImpl(Object object) {
if (object == null) {
throw new IllegalArgumentException("object must not be null");
}
this.object = object;
}
private static URL toURL(String systemId) {
try {
return new URL(systemId);
}
catch (MalformedURLException e) {
return null;
}
}
public URL getURL() {
return url;
}
public void setURL(URL url) {
this.url = url;
}
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
public int getLineNumber() {
return lineNumber;
}
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
public int getColumnNumber() {
return columnNumber;
}
public void setColumnNumber(int columnNumber) {
this.columnNumber = columnNumber;
}
public Object getObject() {
return object;
}
public void setObject(Object object) {
this.object = object;
}
public Node getNode() {
return node;
}
public void setNode(Node node) {
this.node = node;
}
public String toString() {
return "[node=" + getNode() + ", " +
"object=" + getObject() + ", " +
"url=" + getURL() + ", " +
"line=" + String.valueOf(getLineNumber()) + "," +
"col=" + String.valueOf(getColumnNumber()) + "," +
"offset=" + String.valueOf(getOffset()) + "]";
}
}
| 1,217 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/helpers/ParseConversionEventImpl.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.helpers;
import javax.xml.bind.ParseConversionEvent;
import javax.xml.bind.ValidationEventLocator;
public class ParseConversionEventImpl extends ValidationEventImpl implements ParseConversionEvent {
public ParseConversionEventImpl(int severity, String message, ValidationEventLocator locator) {
super(severity, message, locator);
}
public ParseConversionEventImpl(int severity, String message, ValidationEventLocator locator, Throwable linkedException) {
super(severity, message, locator, linkedException);
}
}
| 1,218 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/helpers/ValidationEventImpl.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.helpers;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventLocator;
public class ValidationEventImpl implements ValidationEvent {
private int severity;
private String message;
private Throwable linkedException;
private ValidationEventLocator locator;
public ValidationEventImpl(int severity, String message, ValidationEventLocator locator) {
this(severity, message, locator, null);
}
public ValidationEventImpl(int severity, String message, ValidationEventLocator locator, Throwable linkedException) {
setSeverity(severity);
this.message = message;
this.locator = locator;
this.linkedException = linkedException;
}
public int getSeverity() {
return severity;
}
public void setSeverity(int severity) {
if (severity != 0 && severity != 1 && severity != 2) {
throw new IllegalArgumentException("Illegal severity");
}
this.severity = severity;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Throwable getLinkedException() {
return linkedException;
}
public void setLinkedException(Throwable linkedException) {
this.linkedException = linkedException;
}
public ValidationEventLocator getLocator() {
return locator;
}
public void setLocator(ValidationEventLocator locator) {
this.locator = locator;
}
public String toString() {
String s;
switch (getSeverity()) {
case WARNING:
s = "WARNING";
break;
case ERROR:
s = "ERROR";
break;
case FATAL_ERROR:
s = "FATAL_ERROR";
break;
default:
s = String.valueOf(getSeverity());
break;
}
return "[severity=" + s + ", message=" + getMessage() + ", locator=" + getLocator() + "]";
}
}
| 1,219 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/helpers/PrintConversionEventImpl.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.helpers;
import javax.xml.bind.PrintConversionEvent;
import javax.xml.bind.ValidationEventLocator;
public class PrintConversionEventImpl extends ValidationEventImpl implements PrintConversionEvent {
public PrintConversionEventImpl(int severity, String message, ValidationEventLocator locator) {
super(severity, message, locator);
}
public PrintConversionEventImpl(int severity, String message, ValidationEventLocator locator, Throwable linkedException) {
super(severity, message, locator, linkedException);
}
}
| 1,220 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/helpers/AbstractMarshallerImpl.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.helpers;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.io.File;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.attachment.AttachmentMarshaller;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.Result;
import javax.xml.validation.Schema;
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
public abstract class AbstractMarshallerImpl implements Marshaller {
static String aliases[] = {
"UTF-8", "UTF8",
"UTF-16", "Unicode",
"UTF-16BE", "UnicodeBigUnmarked",
"UTF-16LE", "UnicodeLittleUnmarked",
"US-ASCII", "ASCII",
"TIS-620", "TIS620",
"ISO-10646-UCS-2", "Unicode",
"EBCDIC-CP-US", "cp037",
"EBCDIC-CP-CA", "cp037",
"EBCDIC-CP-NL", "cp037",
"EBCDIC-CP-WT", "cp037",
"EBCDIC-CP-DK", "cp277",
"EBCDIC-CP-NO", "cp277",
"EBCDIC-CP-FI", "cp278",
"EBCDIC-CP-SE", "cp278",
"EBCDIC-CP-IT", "cp280",
"EBCDIC-CP-ES", "cp284",
"EBCDIC-CP-GB", "cp285",
"EBCDIC-CP-FR", "cp297",
"EBCDIC-CP-AR1", "cp420",
"EBCDIC-CP-HE", "cp424",
"EBCDIC-CP-BE", "cp500",
"EBCDIC-CP-CH", "cp500",
"EBCDIC-CP-ROECE", "cp870",
"EBCDIC-CP-YU", "cp870",
"EBCDIC-CP-IS", "cp871",
"EBCDIC-CP-AR2", "cp918"
};
private ValidationEventHandler eventHandler = new DefaultValidationEventHandler();
private String encoding = "UTF-8";
private String schemaLocation;
private String noNSSchemaLocation;
private boolean formattedOutput;
private boolean fragment;
public void marshal(Object obj, File file) throws JAXBException {
checkNotNull(obj, "obj", file, "file");
try {
OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
try {
marshal(obj, new StreamResult(os));
} finally {
os.close();
}
} catch (IOException e) {
throw new JAXBException(e);
}
}
public final void marshal(Object obj, OutputStream os) throws JAXBException {
checkNotNull(obj, "obj", os, "os");
marshal(obj, new StreamResult(os));
}
public final void marshal(Object obj, Writer w) throws JAXBException {
checkNotNull(obj, "obj", w, "writer");
marshal(obj, new StreamResult(w));
}
public final void marshal(Object obj, ContentHandler handler) throws JAXBException {
checkNotNull(obj, "obj", handler, "handler");
marshal(obj, new SAXResult(handler));
}
public final void marshal(Object obj, Node node) throws JAXBException {
checkNotNull(obj, "obj", node, "node");
marshal(obj, new DOMResult(node));
}
public Node getNode(Object obj) throws JAXBException {
checkNotNull(obj, "obj", "foo", "bar");
throw new UnsupportedOperationException();
}
protected String getEncoding() {
return encoding;
}
protected void setEncoding(String encoding) {
this.encoding = encoding;
}
protected String getSchemaLocation() {
return schemaLocation;
}
protected void setSchemaLocation(String location) {
schemaLocation = location;
}
protected String getNoNSSchemaLocation() {
return noNSSchemaLocation;
}
protected void setNoNSSchemaLocation(String location) {
noNSSchemaLocation = location;
}
protected boolean isFormattedOutput() {
return formattedOutput;
}
protected void setFormattedOutput(boolean v) {
formattedOutput = v;
}
protected boolean isFragment() {
return fragment;
}
protected void setFragment(boolean v) {
fragment = v;
}
protected String getJavaEncoding(String encoding) throws UnsupportedEncodingException {
try {
"dummy".getBytes(encoding);
return encoding;
}
catch (UnsupportedEncodingException e) {
}
for (int i = 0; i < aliases.length; i += 2) {
if (encoding.equals(aliases[i])) {
"dummy".getBytes(aliases[i + 1]);
return aliases[i + 1];
}
}
throw new UnsupportedEncodingException(encoding);
}
public void setProperty(String name, Object value) throws PropertyException {
if (name == null) {
throw new IllegalArgumentException("name must not be null");
}
if (JAXB_ENCODING.equals(name)) {
checkString(name, value);
setEncoding((String) value);
} else if (JAXB_FORMATTED_OUTPUT.equals(name)) {
checkBoolean(name, value);
setFormattedOutput(((Boolean) value).booleanValue());
} else if (JAXB_NO_NAMESPACE_SCHEMA_LOCATION.equals(name)) {
checkString(name, value);
setNoNSSchemaLocation((String) value);
} else if (JAXB_SCHEMA_LOCATION.equals(name)) {
checkString(name, value);
setSchemaLocation((String) value);
} else if (JAXB_FRAGMENT.equals(name)) {
checkBoolean(name, value);
setFragment(((Boolean) value).booleanValue());
} else {
throw new PropertyException(name, value);
}
}
public Object getProperty(String name) throws PropertyException {
if (name == null) {
throw new IllegalArgumentException("name must not be null");
}
if (JAXB_ENCODING.equals(name)) {
return getEncoding();
} else if (JAXB_FORMATTED_OUTPUT.equals(name)) {
return isFormattedOutput() ? Boolean.TRUE : Boolean.FALSE;
} else if (JAXB_NO_NAMESPACE_SCHEMA_LOCATION.equals(name)) {
return getNoNSSchemaLocation();
} else if (JAXB_SCHEMA_LOCATION.equals(name)) {
return getSchemaLocation();
} else if (JAXB_FRAGMENT.equals(name)) {
return isFragment() ? Boolean.TRUE : Boolean.FALSE;
} else {
throw new PropertyException(name);
}
}
public ValidationEventHandler getEventHandler() throws JAXBException {
return eventHandler;
}
public void setEventHandler(ValidationEventHandler handler) throws JAXBException {
if (handler == null) {
eventHandler = new DefaultValidationEventHandler();
} else {
eventHandler = handler;
}
}
private void checkBoolean(String name, Object value) throws PropertyException {
if (!(value instanceof Boolean)) {
throw new PropertyException(name + " must be a boolean");
}
}
private void checkString(String name, Object value) throws PropertyException {
if (!(value instanceof String)) {
throw new PropertyException(name + " must be a string");
}
}
private void checkNotNull(Object o1, String o1Name, Object o2, String o2Name) {
if (o1 == null) {
throw new IllegalArgumentException(o1Name + " must not be null");
}
if (o2 == null) {
throw new IllegalArgumentException(o2Name + " must not be null");
}
}
public void marshal(Object obj, XMLEventWriter writer)
throws JAXBException {
throw new UnsupportedOperationException();
}
public void marshal(Object obj, XMLStreamWriter writer) throws JAXBException {
throw new UnsupportedOperationException();
}
public void setSchema(Schema schema) {
throw new UnsupportedOperationException();
}
public Schema getSchema() {
throw new UnsupportedOperationException();
}
public void setAdapter(XmlAdapter adapter) {
if (adapter == null) {
throw new IllegalArgumentException();
}
setAdapter((Class<XmlAdapter>) adapter.getClass(), adapter);
}
public <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter) {
throw new UnsupportedOperationException();
}
public <A extends XmlAdapter> A getAdapter(Class<A> type) {
throw new UnsupportedOperationException();
}
public void setAttachmentMarshaller(AttachmentMarshaller am) {
throw new UnsupportedOperationException();
}
public AttachmentMarshaller getAttachmentMarshaller() {
throw new UnsupportedOperationException();
}
public void setListener(javax.xml.bind.Marshaller.Listener listener) {
throw new UnsupportedOperationException();
}
public javax.xml.bind.Marshaller.Listener getListener() {
throw new UnsupportedOperationException();
}
}
| 1,221 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/helpers/NotIdentifiableEventImpl.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.helpers;
import javax.xml.bind.NotIdentifiableEvent;
import javax.xml.bind.ValidationEventLocator;
public class NotIdentifiableEventImpl extends ValidationEventImpl implements NotIdentifiableEvent {
public NotIdentifiableEventImpl(int severity, String message, ValidationEventLocator locator) {
super(severity, message, locator);
}
public NotIdentifiableEventImpl(int severity, String message, ValidationEventLocator locator, Throwable linkedException) {
super(severity, message, locator, linkedException);
}
}
| 1,222 |
0 | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind | Create_ds/geronimo-specs/geronimo-jaxb_2.1_spec/src/main/java/javax/xml/bind/helpers/DefaultValidationEventHandler.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.xml.bind.helpers;
import java.net.URL;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventLocator;
import org.w3c.dom.Node;
public class DefaultValidationEventHandler implements ValidationEventHandler {
public boolean handleEvent(ValidationEvent event) {
if (event == null) {
throw new IllegalArgumentException();
}
String severity = null;
boolean retVal = false;
switch(event.getSeverity()) {
case ValidationEvent.WARNING:
severity = "[WARNING]: ";
retVal = true;
break;
case ValidationEvent.ERROR:
severity = "[ERROR]: ";
retVal = false;
break;
case ValidationEvent.FATAL_ERROR:
severity = "[FATAL_ERROR]: ";
retVal = false;
break;
}
String location = getLocation(event);
System.out.println("DefaultValidationEventHandler " + severity + " " + event.getMessage() + "\n Location: " + location);
return retVal;
}
private String getLocation(ValidationEvent event) {
StringBuffer msg = new StringBuffer();
ValidationEventLocator locator = event.getLocator();
if (locator != null) {
URL url = locator.getURL();
Object obj = locator.getObject();
Node node = locator.getNode();
int line = locator.getLineNumber();
if(url != null || line != -1) {
msg.append("line ").append(line);
if(url != null) {
msg.append(" of ").append(url);
}
} else {
if (obj != null) {
msg.append(" obj: ").append(obj.toString());
} else if(node != null) {
msg.append(" node: ").append(node.toString());
}
}
} else {
msg.append("unavailable");
}
return msg.toString();
}
}
| 1,223 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/test/java/org/apache/geronimo/specs | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/test/java/org/apache/geronimo/specs/jsonb/JsonbConfigTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.geronimo.specs.jsonb;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.json.bind.JsonbConfig;
import javax.json.bind.adapter.JsonbAdapter;
import org.junit.jupiter.api.Test;
class JsonbConfigTest {
@Test
void accumulate() {
final JsonbConfig jsonbConfig = new JsonbConfig()
.withAdapters(new PassthroughIntegerAdapter())
.withAdapters(new PassthroughStringAdapter());
final Object adapters = jsonbConfig.getProperty(JsonbConfig.ADAPTERS).orElseThrow(AssertionError::new);
assertTrue(JsonbAdapter[].class.isAssignableFrom(adapters.getClass()));
assertEquals(2, JsonbAdapter[].class.cast(adapters).length);
}
public static class PassthroughStringAdapter implements JsonbAdapter<String, String> {
@Override
public String adaptToJson(final String obj) {
return obj;
}
@Override
public String adaptFromJson(final String obj) {
return obj;
}
}
public static class PassthroughIntegerAdapter implements JsonbAdapter<Integer, Integer> {
@Override
public Integer adaptToJson(final Integer obj) {
return obj;
}
@Override
public Integer adaptFromJson(final Integer obj) {
return obj;
}
}
}
| 1,224 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/JsonbConfig.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind;
import javax.json.bind.adapter.JsonbAdapter;
import javax.json.bind.config.PropertyNamingStrategy;
import javax.json.bind.config.PropertyVisibilityStrategy;
import javax.json.bind.serializer.JsonbDeserializer;
import javax.json.bind.serializer.JsonbSerializer;
import java.lang.reflect.Array;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
public class JsonbConfig {
private final Map<String, Object> configuration = new HashMap<>();
public static final String FORMATTING = "jsonb.formatting";
public static final String ENCODING = "jsonb.encoding";
public static final String PROPERTY_NAMING_STRATEGY = "jsonb.property-naming-strategy";
public static final String PROPERTY_ORDER_STRATEGY = "jsonb.property-order-strategy";
public static final String NULL_VALUES = "jsonb.null-values";
public static final String STRICT_IJSON = "jsonb.strict-ijson";
public static final String PROPERTY_VISIBILITY_STRATEGY = "jsonb.property-visibility-strategy";
public static final String ADAPTERS = "jsonb.adapters";
public static final String BINARY_DATA_STRATEGY = "jsonb.binary-data-strategy";
public static final String DATE_FORMAT = "jsonb.date-format";
public static final String LOCALE = "jsonb.locale";
public static final String SERIALIZERS = "jsonb.serializers";
public static final String DESERIALIZERS = "jsonb.derializers";
public final JsonbConfig withDateFormat(final String dateFormat, final Locale locale) {
return setProperty(DATE_FORMAT, dateFormat).setProperty(LOCALE, locale != null ? locale : Locale.getDefault());
}
public final JsonbConfig withLocale(final Locale locale) {
return setProperty(LOCALE, locale);
}
public final JsonbConfig setProperty(final String name, final Object value) {
configuration.put(name, value);
return this;
}
public final Optional<Object> getProperty(final String name) {
return Optional.ofNullable(configuration.get(name));
}
public final Map<String, Object> getAsMap() {
return Collections.unmodifiableMap(configuration);
}
public final JsonbConfig withFormatting(final Boolean formatted) {
return setProperty(FORMATTING, formatted);
}
public final JsonbConfig withNullValues(final Boolean serializeNullValues) {
return setProperty(NULL_VALUES, serializeNullValues);
}
public final JsonbConfig withEncoding(final String encoding) {
return setProperty(ENCODING, encoding);
}
public final JsonbConfig withStrictIJSON(final Boolean enabled) {
return setProperty(STRICT_IJSON, enabled);
}
public final JsonbConfig withPropertyNamingStrategy(final PropertyNamingStrategy propertyNamingStrategy) {
return setProperty(PROPERTY_NAMING_STRATEGY, propertyNamingStrategy);
}
public final JsonbConfig withPropertyNamingStrategy(final String propertyNamingStrategy) {
return setProperty(PROPERTY_NAMING_STRATEGY, propertyNamingStrategy);
}
public final JsonbConfig withPropertyOrderStrategy(final String propertyOrderStrategy) {
return setProperty(PROPERTY_ORDER_STRATEGY, propertyOrderStrategy);
}
public final JsonbConfig withPropertyVisibilityStrategy(final PropertyVisibilityStrategy propertyVisibilityStrategy) {
return setProperty(PROPERTY_VISIBILITY_STRATEGY, propertyVisibilityStrategy);
}
public final JsonbConfig withAdapters(final JsonbAdapter... adapters) {
return accumulate(ADAPTERS, adapters, JsonbAdapter.class);
}
public final JsonbConfig withBinaryDataStrategy(final String binaryDataStrategy) {
return setProperty(BINARY_DATA_STRATEGY, binaryDataStrategy);
}
public final JsonbConfig withSerializers(final JsonbSerializer... serializers) {
return accumulate(SERIALIZERS, serializers, JsonbSerializer.class);
}
public final JsonbConfig withDeserializers(final JsonbDeserializer... deserializers) {
return accumulate(DESERIALIZERS, deserializers, JsonbDeserializer.class);
}
private <T> JsonbConfig accumulate(final String key, final T[] values, final Class<T> componentType) {
if (values == null || values.length == 0) {
return this;
}
final Optional<Object> opt = getProperty(key);
if (opt.isPresent()) {
final T[] existing = (T[]) opt.get();
final T[] aggregated = (T[]) Array.newInstance(componentType, existing.length + values.length);
System.arraycopy(existing, 0, aggregated, 0, existing.length);
System.arraycopy(values, 0, aggregated, existing.length, values.length);
return setProperty(key, aggregated);
}
return setProperty(key, values);
}
}
| 1,225 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/Jsonb.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.lang.reflect.Type;
public interface Jsonb extends AutoCloseable {
<T> T fromJson(String str, Class<T> type) throws JsonbException;
<T> T fromJson(String str, Type runtimeType) throws JsonbException;
<T> T fromJson(Reader reader, Class<T> type) throws JsonbException;
<T> T fromJson(Reader reader, Type runtimeType) throws JsonbException;
<T> T fromJson(InputStream stream, Class<T> type) throws JsonbException;
<T> T fromJson(InputStream stream, Type runtimeType) throws JsonbException;
String toJson(Object object) throws JsonbException;
String toJson(Object object, Type runtimeType) throws JsonbException;
void toJson(Object object, Writer writer) throws JsonbException;
void toJson(Object object, Type runtimeType, Writer writer) throws JsonbException;
void toJson(Object object, OutputStream stream) throws JsonbException;
void toJson(Object object, Type runtimeType, OutputStream stream) throws JsonbException;
}
| 1,226 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/JsonbException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind;
public class JsonbException extends RuntimeException {
private static final long serialVersionUID = 1L;
public JsonbException(final String message) {
super(message);
}
public JsonbException(final String message, final Throwable cause) {
super(message, cause);
}
}
| 1,227 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/JsonbBuilder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind;
import javax.json.bind.spi.JsonbProvider;
import javax.json.spi.JsonProvider;
public interface JsonbBuilder {
JsonbBuilder withConfig(final JsonbConfig config);
JsonbBuilder withProvider(final JsonProvider jsonpProvider);
Jsonb build();
static Jsonb create() {
return JsonbProvider.provider().create().build();
}
static Jsonb create(final JsonbConfig config) {
return JsonbProvider.provider().create().withConfig(config).build();
}
static JsonbBuilder newBuilder() {
return JsonbProvider.provider().create();
}
static JsonbBuilder newBuilder(final String providerName) {
return JsonbProvider.provider(providerName).create();
}
static JsonbBuilder newBuilder(final JsonbProvider provider) {
return provider.create();
}
}
| 1,228 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/serializer/DeserializationContext.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.serializer;
import javax.json.stream.JsonParser;
import java.lang.reflect.Type;
public interface DeserializationContext {
/**
* JsonParser cursor is at KEY_NAME event.
*/
<T> T deserialize(Class<T> clazz, JsonParser parser);
<T> T deserialize(Type type, JsonParser parser);
}
| 1,229 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/serializer/JsonbSerializer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.serializer;
import javax.json.stream.JsonGenerator;
public interface JsonbSerializer<T> {
void serialize(T obj, JsonGenerator generator, SerializationContext ctx);
}
| 1,230 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/serializer/JsonbDeserializer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.serializer;
import javax.json.stream.JsonParser;
import java.lang.reflect.Type;
public interface JsonbDeserializer<T> {
/**
* JsonParser is at START_OBJECT event.
*/
T deserialize(JsonParser parser, DeserializationContext ctx, Type rtType);
}
| 1,231 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/serializer/SerializationContext.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.serializer;
import javax.json.stream.JsonGenerator;
public interface SerializationContext {
<T> void serialize(String key, T object, JsonGenerator generator);
<T> void serialize(T object, JsonGenerator generator);
}
| 1,232 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/config/BinaryDataStrategy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.config;
public final class BinaryDataStrategy {
private BinaryDataStrategy() {
// no-op
}
public static final String BYTE = "BYTE";
public static final String BASE_64 = "BASE_64";
public static final String BASE_64_URL = "BASE_64_URL";
}
| 1,233 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/config/PropertyOrderStrategy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.config;
public final class PropertyOrderStrategy {
private PropertyOrderStrategy() {
// no-op
}
public static final String LEXICOGRAPHICAL = "LEXICOGRAPHICAL";
public static final String ANY = "ANY";
public static final String REVERSE = "REVERSE";
}
| 1,234 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/config/PropertyVisibilityStrategy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.config;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public interface PropertyVisibilityStrategy {
boolean isVisible(Field field);
boolean isVisible(Method method);
}
| 1,235 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/config/PropertyNamingStrategy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.config;
public interface PropertyNamingStrategy {
String IDENTITY = "IDENTITY";
String LOWER_CASE_WITH_DASHES = "LOWER_CASE_WITH_DASHES";
String LOWER_CASE_WITH_UNDERSCORES = "LOWER_CASE_WITH_UNDERSCORES";
String UPPER_CAMEL_CASE = "UPPER_CAMEL_CASE";
String UPPER_CAMEL_CASE_WITH_SPACES = "UPPER_CAMEL_CASE_WITH_SPACES";
String CASE_INSENSITIVE = "CASE_INSENSITIVE";
String translateName(String propertyName);
}
| 1,236 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbNumberFormat.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({
ElementType.ANNOTATION_TYPE, ElementType.FIELD,
ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER,
ElementType.PACKAGE
})
public @interface JsonbNumberFormat {
String DEFAULT_LOCALE = "##default";
String value() default "";
String locale() default DEFAULT_LOCALE;
}
| 1,237 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbAnnotation.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonbAnnotation {
}
| 1,238 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbProperty.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({
ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER
})
public @interface JsonbProperty {
String value() default "";
boolean nillable() default false;
}
| 1,239 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbTypeSerializer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import javax.json.bind.serializer.JsonbSerializer;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ANNOTATION_TYPE, TYPE, FIELD, METHOD})
public @interface JsonbTypeSerializer {
Class<? extends JsonbSerializer> value();
} | 1,240 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbDateFormat.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({
ElementType.ANNOTATION_TYPE, ElementType.FIELD,
ElementType.METHOD, ElementType.TYPE,
ElementType.PARAMETER, ElementType.PACKAGE
})
public @interface JsonbDateFormat {
String DEFAULT_LOCALE = "##default";
String DEFAULT_FORMAT = "##default";
String TIME_IN_MILLIS = "##time-in-millis";
String value() default DEFAULT_FORMAT;
String locale() default DEFAULT_LOCALE;
}
| 1,241 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbTypeAdapter.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import javax.json.bind.adapter.JsonbAdapter;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD})
public @interface JsonbTypeAdapter {
Class<? extends JsonbAdapter> value();
}
| 1,242 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbTypeDeserializer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import javax.json.bind.serializer.JsonbDeserializer;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ANNOTATION_TYPE, TYPE, FIELD, METHOD})
public @interface JsonbTypeDeserializer {
Class<? extends JsonbDeserializer> value();
} | 1,243 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbCreator.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR})
public @interface JsonbCreator {
}
| 1,244 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbPropertyOrder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE})
public @interface JsonbPropertyOrder {
String[] value();
}
| 1,245 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbTransient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD})
public @interface JsonbTransient {
}
| 1,246 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbNillable.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.PACKAGE})
public @interface JsonbNillable {
boolean value() default true;
}
| 1,247 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/annotation/JsonbVisibility.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.annotation;
import javax.json.bind.config.PropertyVisibilityStrategy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@JsonbAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({
ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.PACKAGE
})
public @interface JsonbVisibility {
Class<? extends PropertyVisibilityStrategy> value();
}
| 1,248 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/adapter/JsonbAdapter.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.adapter;
public interface JsonbAdapter<OriginalType, JsonType> {
JsonType adaptToJson(OriginalType obj) throws Exception;
OriginalType adaptFromJson(JsonType obj) throws Exception;
} | 1,249 |
0 | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind | Create_ds/geronimo-specs/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/spi/JsonbProvider.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package javax.json.bind.spi;
import javax.json.bind.JsonbBuilder;
import javax.json.bind.JsonbException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.List;
import java.util.ServiceLoader;
public abstract class JsonbProvider {
private static final String DEFAULT_PROVIDER = "org.apache.johnzon.jsonb.JohnzonProvider";
public static JsonbProvider provider() {
if (System.getSecurityManager() != null) {
return AccessController.doPrivileged((PrivilegedAction<JsonbProvider>) () -> doLoadProvider(null));
}
return doLoadProvider(null);
}
public static JsonbProvider provider(final String providerFqn) {
if (providerFqn == null) {
throw new IllegalArgumentException();
}
if (System.getSecurityManager() != null) {
return AccessController.doPrivileged((PrivilegedAction<JsonbProvider>) () -> doLoadProvider(providerFqn));
}
return doLoadProvider(providerFqn);
}
private static JsonbProvider doLoadProvider(final String providerFqn) {
for (final JsonbProvider provider : ServiceLoader.load(JsonbProvider.class)) {
if (providerFqn == null) {
return provider;
}
else if (providerFqn.equals(provider.getClass().getName())) {
return provider;
}
}
if (providerFqn != null) {
final String msg = providerFqn + " not found";
throw new JsonbException(msg, new ClassNotFoundException(msg));
}
try {
return JsonbProvider.class.cast(Thread.currentThread().getContextClassLoader().loadClass(DEFAULT_PROVIDER).newInstance());
} catch (final ClassNotFoundException cnfe) {
throw new JsonbException(DEFAULT_PROVIDER + " not found", cnfe);
} catch (final Exception x) {
throw new JsonbException(DEFAULT_PROVIDER + " couldn't be instantiated: " + x, x);
}
}
public abstract JsonbBuilder create();
}
| 1,250 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/JspWriter.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
import java.io.IOException;
/**
* <p>
* The actions and template data in a JSP page is written using the
* JspWriter object that is referenced by the implicit variable out which
* is initialized automatically using methods in the PageContext object.
*<p>
* This abstract class emulates some of the functionality found in the
* java.io.BufferedWriter and java.io.PrintWriter classes,
* however it differs in that it throws java.io.IOException from the print
* methods while PrintWriter does not.
* <p><B>Buffering</B>
* <p>
* The initial JspWriter object is associated with the PrintWriter object
* of the ServletResponse in a way that depends on whether the page is or
* is not buffered. If the page is not buffered, output written to this
* JspWriter object will be written through to the PrintWriter directly,
* which will be created if necessary by invoking the getWriter() method
* on the response object. But if the page is buffered, the PrintWriter
* object will not be created until the buffer is flushed and
* operations like setContentType() are legal. Since this flexibility
* simplifies programming substantially, buffering is the default for JSP
* pages.
* <p>
* Buffering raises the issue of what to do when the buffer is
* exceeded. Two approaches can be taken:
* <ul>
* <li>
* Exceeding the buffer is not a fatal error; when the buffer is
* exceeded, just flush the output.
* <li>
* Exceeding the buffer is a fatal error; when the buffer is exceeded,
* raise an exception.
* </ul>
* <p>
* Both approaches are valid, and thus both are supported in the JSP
* technology. The behavior of a page is controlled by the autoFlush
* attribute, which defaults to true. In general, JSP pages that need to
* be sure that correct and complete data has been sent to their client
* may want to set autoFlush to false, with a typical case being that
* where the client is an application itself. On the other hand, JSP
* pages that send data that is meaningful even when partially
* constructed may want to set autoFlush to true; such as when the
* data is sent for immediate display through a browser. Each application
* will need to consider their specific needs.
* <p>
* An alternative considered was to make the buffer size unbounded; but,
* this had the disadvantage that runaway computations would consume an
* unbounded amount of resources.
* <p>
* The "out" implicit variable of a JSP implementation class is of this type.
* If the page directive selects autoflush="true" then all the I/O operations
* on this class shall automatically flush the contents of the buffer if an
* overflow condition would result if the current operation were performed
* without a flush. If autoflush="false" then all the I/O operations on this
* class shall throw an IOException if performing the current operation would
* result in a buffer overflow condition.
*
* @see java.io.Writer
* @see java.io.BufferedWriter
* @see java.io.PrintWriter
*/
abstract public class JspWriter extends java.io.Writer {
/**
* Constant indicating that the Writer is not buffering output.
*/
public static final int NO_BUFFER = 0;
/**
* Constant indicating that the Writer is buffered and is using the
* implementation default buffer size.
*/
public static final int DEFAULT_BUFFER = -1;
/**
* Constant indicating that the Writer is buffered and is unbounded; this
* is used in BodyContent.
*/
public static final int UNBOUNDED_BUFFER = -2;
/**
* Protected constructor.
*
* @param bufferSize the size of the buffer to be used by the JspWriter
* @param autoFlush whether the JspWriter should be autoflushing
*/
protected JspWriter(int bufferSize, boolean autoFlush) {
this.bufferSize = bufferSize;
this.autoFlush = autoFlush;
}
/**
* Write a line separator. The line separator string is defined by the
* system property <tt>line.separator</tt>, and is not necessarily a single
* newline ('\n') character.
*
* @exception IOException If an I/O error occurs
*/
abstract public void newLine() throws IOException;
/**
* Print a boolean value. The string produced by <code>{@link
* java.lang.String#valueOf(boolean)}</code> is written to the
* JspWriter's buffer or, if no buffer is used, directly to the
* underlying writer.
*
* @param b The <code>boolean</code> to be printed
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(boolean b) throws IOException;
/**
* Print a character. The character is written to the
* JspWriter's buffer or, if no buffer is used, directly to the
* underlying writer.
*
* @param c The <code>char</code> to be printed
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(char c) throws IOException;
/**
* Print an integer. The string produced by <code>{@link
* java.lang.String#valueOf(int)}</code> is written to the
* JspWriter's buffer or, if no buffer is used, directly to the
* underlying writer.
*
* @param i The <code>int</code> to be printed
* @see java.lang.Integer#toString(int)
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(int i) throws IOException;
/**
* Print a long integer. The string produced by <code>{@link
* java.lang.String#valueOf(long)}</code> is written to the
* JspWriter's buffer or, if no buffer is used, directly to the
* underlying writer.
*
* @param l The <code>long</code> to be printed
* @see java.lang.Long#toString(long)
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(long l) throws IOException;
/**
* Print a floating-point number. The string produced by <code>{@link
* java.lang.String#valueOf(float)}</code> is written to the
* JspWriter's buffer or, if no buffer is used, directly to the
* underlying writer.
*
* @param f The <code>float</code> to be printed
* @see java.lang.Float#toString(float)
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(float f) throws IOException;
/**
* Print a double-precision floating-point number. The string produced by
* <code>{@link java.lang.String#valueOf(double)}</code> is written to
* the JspWriter's buffer or, if no buffer is used, directly to the
* underlying writer.
*
* @param d The <code>double</code> to be printed
* @see java.lang.Double#toString(double)
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(double d) throws IOException;
/**
* Print an array of characters. The characters are written to the
* JspWriter's buffer or, if no buffer is used, directly to the
* underlying writer.
*
* @param s The array of chars to be printed
*
* @throws NullPointerException If <code>s</code> is <code>null</code>
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(char s[]) throws IOException;
/**
* Print a string. If the argument is <code>null</code> then the string
* <code>"null"</code> is printed. Otherwise, the string's characters are
* written to the JspWriter's buffer or, if no buffer is used, directly
* to the underlying writer.
*
* @param s The <code>String</code> to be printed
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(String s) throws IOException;
/**
* Print an object. The string produced by the <code>{@link
* java.lang.String#valueOf(Object)}</code> method is written to the
* JspWriter's buffer or, if no buffer is used, directly to the
* underlying writer.
*
* @param obj The <code>Object</code> to be printed
* @see java.lang.Object#toString()
* @throws java.io.IOException If an error occured while writing
*/
abstract public void print(Object obj) throws IOException;
/**
* Terminate the current line by writing the line separator string. The
* line separator string is defined by the system property
* <code>line.separator</code>, and is not necessarily a single newline
* character (<code>'\n'</code>).
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println() throws IOException;
/**
* Print a boolean value and then terminate the line. This method behaves
* as though it invokes <code>{@link #print(boolean)}</code> and then
* <code>{@link #println()}</code>.
*
* @param x the boolean to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(boolean x) throws IOException;
/**
* Print a character and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(char)}</code> and then <code>{@link
* #println()}</code>.
*
* @param x the char to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(char x) throws IOException;
/**
* Print an integer and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(int)}</code> and then <code>{@link
* #println()}</code>.
*
* @param x the int to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(int x) throws IOException;
/**
* Print a long integer and then terminate the line. This method behaves
* as though it invokes <code>{@link #print(long)}</code> and then
* <code>{@link #println()}</code>.
*
* @param x the long to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(long x) throws IOException;
/**
* Print a floating-point number and then terminate the line. This method
* behaves as though it invokes <code>{@link #print(float)}</code> and then
* <code>{@link #println()}</code>.
*
* @param x the float to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(float x) throws IOException;
/**
* Print a double-precision floating-point number and then terminate the
* line. This method behaves as though it invokes <code>{@link
* #print(double)}</code> and then <code>{@link #println()}</code>.
*
* @param x the double to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(double x) throws IOException;
/**
* Print an array of characters and then terminate the line. This method
* behaves as though it invokes <code>print(char[])</code> and then
* <code>println()</code>.
*
* @param x the char[] to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(char x[]) throws IOException;
/**
* Print a String and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(String)}</code> and then
* <code>{@link #println()}</code>.
*
* @param x the String to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(String x) throws IOException;
/**
* Print an Object and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(Object)}</code> and then
* <code>{@link #println()}</code>.
*
* @param x the Object to write
* @throws java.io.IOException If an error occured while writing
*/
abstract public void println(Object x) throws IOException;
/**
* Clear the contents of the buffer. If the buffer has been already
* been flushed then the clear operation shall throw an IOException
* to signal the fact that some data has already been irrevocably
* written to the client response stream.
*
* @throws IOException If an I/O error occurs
*/
abstract public void clear() throws IOException;
/**
* Clears the current contents of the buffer. Unlike clear(), this
* method will not throw an IOException if the buffer has already been
* flushed. It merely clears the current content of the buffer and
* returns.
*
* @throws IOException If an I/O error occurs
*/
abstract public void clearBuffer() throws IOException;
/**
* Flush the stream. If the stream has saved any characters from the
* various write() methods in a buffer, write them immediately to their
* intended destination. Then, if that destination is another character or
* byte stream, flush it. Thus one flush() invocation will flush all the
* buffers in a chain of Writers and OutputStreams.
* <p>
* The method may be invoked indirectly if the buffer size is exceeded.
* <p>
* Once a stream has been closed,
* further write() or flush() invocations will cause an IOException to be
* thrown.
*
* @exception IOException If an I/O error occurs
*/
abstract public void flush() throws IOException;
/**
* Close the stream, flushing it first.
* <p>
* This method needs not be invoked explicitly for the initial JspWriter
* as the code generated by the JSP container will automatically
* include a call to close().
* <p>
* Closing a previously-closed stream, unlike flush(), has no effect.
*
* @exception IOException If an I/O error occurs
*/
abstract public void close() throws IOException;
/**
* This method returns the size of the buffer used by the JspWriter.
*
* @return the size of the buffer in bytes, or 0 is unbuffered.
*/
public int getBufferSize() { return bufferSize; }
/**
* This method returns the number of unused bytes in the buffer.
*
* @return the number of bytes unused in the buffer
*/
abstract public int getRemaining();
/**
* This method indicates whether the JspWriter is autoFlushing.
*
* @return if this JspWriter is auto flushing or throwing IOExceptions
* on buffer overflow conditions
*/
public boolean isAutoFlush() { return autoFlush; }
/*
* fields
*/
/**
* The size of the buffer used by the JspWriter.
*/
protected int bufferSize;
/**
* Whether the JspWriter is autoflushing.
*/
protected boolean autoFlush;
}
| 1,251 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/JspApplicationContext.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
import javax.el.ELContextListener;
import javax.el.ELResolver;
import javax.el.ExpressionFactory;
/**
* <p>
* Stores <i>application</i>-scoped information for the JSP container.
* </p>
* @since 2.1
*/
public interface JspApplicationContext {
/**
* <p>
* Registers an <code>ELContextListener</code> that will notified whenever
* a new <code>ELContext</code> is created.
* </p>
* <p>
* At the very least, any <code>ELContext</code> instantiated will have reference
* to the <code>JspContext</code> under <code>JspContext.class</code>.
* </p>
*
* @param listener
*/
public void addELContextListener(ELContextListener listener);
/**
* <p>
* Adds an <code>ELResolver</code> to the chain of EL variable and property management
* within JSP pages and Tag files.
* </p>
* <p>
* JSP has a default set of ELResolvers to chain for all EL evaluation:
* <ul>
* <li><code>ImplicitObjectELResolver</code></li>
* <li><code>ELResolver</code> instances registered with this method</li>
* <li><code>MapELResolver</code></li>
* <li><code>ListELResolver</code></li>
* <li><code>ArrayELResolver</code></li>
* <li><code>BeanELResolver</code></li>
* <li><code>ScopedAttributeELResolver</code></li>
* </ul>
* </p>
*
* @param resolver an additional resolver
* @throws IllegalStateException if called after the application's <code>ServletContextListeners</code> have been initialized.
*/
public void addELResolver(ELResolver resolver) throws IllegalStateException;
/**
* <p>
* Returns the JSP container's <code>ExpressionFactory</code> implementation for EL use.
* </p>
*
* @return an <code>ExpressionFactory</code> implementation
*/
public ExpressionFactory getExpressionFactory();
}
| 1,252 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/JspTagException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
/**
* Exception to be used by a Tag Handler to indicate some unrecoverable
* error.
* This error is to be caught by the top level of the JSP page and will result
* in an error page.
*/
public class JspTagException extends JspException {
/**
* Constructs a new JspTagException with the specified message.
* The message can be written to the server log and/or displayed
* for the user.
*
* @param msg a <code>String</code> specifying the text of
* the exception message
*/
public JspTagException(String msg) {
super( msg );
}
/**
* Constructs a new JspTagException with no message.
*/
public JspTagException() {
super();
}
/**
* Constructs a new JspTagException when the JSP Tag
* needs to throw an exception and include a message
* about the "root cause" exception that interfered with its
* normal operation, including a description message.
*
*
* @param message a <code>String</code> containing
* the text of the exception message
*
* @param rootCause the <code>Throwable</code> exception
* that interfered with the JSP Tag's
* normal operation, making this JSP Tag
* exception necessary
*
* @since 2.0
*/
public JspTagException(String message, Throwable rootCause) {
super( message, rootCause );
}
/**
* Constructs a new JSP Tag exception when the JSP Tag
* needs to throw an exception and include a message
* about the "root cause" exception that interfered with its
* normal operation. The exception's message is based on the localized
* message of the underlying exception.
*
* <p>This method calls the <code>getLocalizedMessage</code> method
* on the <code>Throwable</code> exception to get a localized exception
* message. When subclassing <code>JspTagException</code>,
* this method can be overridden to create an exception message
* designed for a specific locale.
*
* @param rootCause the <code>Throwable</code> exception
* that interfered with the JSP Tag's
* normal operation, making the JSP Tag
* exception necessary
*
* @since 2.0
*/
public JspTagException(Throwable rootCause) {
super( rootCause );
}
}
| 1,253 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/JspEngineInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
/**
* The JspEngineInfo is an abstract class that provides information on the
* current JSP engine.
*/
public abstract class JspEngineInfo {
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public JspEngineInfo() {
}
/**
* Return the version number of the JSP specification that is supported by
* this JSP engine.
* <p>
* Specification version numbers that consists of positive decimal integers
* separated by periods ".", for example, "2.0" or "1.2.3.4.5.6.7".
* This allows an extensible number to be used to
* represent major, minor, micro, etc versions.
* The version number must begin with a number.
* </p>
*
* @return the specification version, null is returned if it is not known
*/
public abstract String getSpecificationVersion();
}
| 1,254 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/HttpJspPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
/**
* The HttpJspPage interface describes the interaction that a JSP Page
* Implementation Class must satisfy when using the HTTP protocol.
*
* <p>
* The behaviour is identical to that of the JspPage, except for the signature
* of the _jspService method, which is now expressible in the Java type
* system and included explicitly in the interface.
*
* @see JspPage
*/
public interface HttpJspPage extends JspPage {
/** The _jspService()method corresponds to the body of the JSP page. This
* method is defined automatically by the JSP container and should never
* be defined by the JSP page author.
* <p>
* If a superclass is specified using the extends attribute, that
* superclass may choose to perform some actions in its service() method
* before or after calling the _jspService() method. See using the extends
* attribute in the JSP_Engine chapter of the JSP specification.
*
* @param request Provides client request information to the JSP.
* @param response Assists the JSP in sending a response to the client.
* @throws ServletException Thrown if an error occurred during the
* processing of the JSP and that the container should take
* appropriate action to clean up the request.
* @throws IOException Thrown if an error occurred while writing the
* response for this page.
*/
public void _jspService(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException;
}
| 1,255 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/JspPage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
import javax.servlet.*;
/**
* The JspPage interface describes the generic interaction that a JSP Page
* Implementation class must satisfy; pages that use the HTTP protocol
* are described by the HttpJspPage interface.
*
* <p><B>Two plus One Methods</B>
* <p>
* The interface defines a protocol with 3 methods; only two of
* them: jspInit() and jspDestroy() are part of this interface as
* the signature of the third method: _jspService() depends on
* the specific protocol used and cannot be expressed in a generic
* way in Java.
* <p>
* A class implementing this interface is responsible for invoking
* the above methods at the appropriate time based on the
* corresponding Servlet-based method invocations.
* <p>
* The jspInit() and jspDestroy() methods can be defined by a JSP
* author, but the _jspService() method is defined automatically
* by the JSP processor based on the contents of the JSP page.
*
* <p><B>_jspService()</B>
* <p>
* The _jspService()method corresponds to the body of the JSP page. This
* method is defined automatically by the JSP container and should never
* be defined by the JSP page author.
* <p>
* If a superclass is specified using the extends attribute, that
* superclass may choose to perform some actions in its service() method
* before or after calling the _jspService() method. See using the extends
* attribute in the JSP_Engine chapter of the JSP specification.
* <p>
* The specific signature depends on the protocol supported by the JSP page.
*
* <pre>
* public void _jspService(<em>ServletRequestSubtype</em> request,
* <em>ServletResponseSubtype</em> response)
* throws ServletException, IOException;
* </pre>
*/
public interface JspPage extends Servlet {
/**
* The jspInit() method is invoked when the JSP page is initialized. It
* is the responsibility of the JSP implementation (and of the class
* mentioned by the extends attribute, if present) that at this point
* invocations to the getServletConfig() method will return the desired
* value.
*
* A JSP page can override this method by including a definition for it
* in a declaration element.
*
* A JSP page should redefine the init() method from Servlet.
*/
public void jspInit();
/**
* The jspDestroy() method is invoked when the JSP page is about to be
* destroyed.
*
* A JSP page can override this method by including a definition for it
* in a declaration element.
*
* A JSP page should redefine the destroy() method from Servlet.
*/
public void jspDestroy();
}
| 1,256 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/JspException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
/**
* A generic exception known to the JSP engine; uncaught
* JspExceptions will result in an invocation of the errorpage
* machinery.
*/
public class JspException extends Exception {
/**
* Construct a JspException.
*/
public JspException() {
}
/**
* Constructs a new JSP exception with the
* specified message. The message can be written
* to the server log and/or displayed for the user.
*
* @param msg a <code>String</code>
* specifying the text of
* the exception message
*
*/
public JspException(String msg) {
super(msg);
}
/**
* Constructs a new JSP exception when the JSP
* needs to throw an exception and include a message
* about the "root cause" exception that interfered with its
* normal operation, including a description message.
*
*
* @param message a <code>String</code> containing
* the text of the exception message
*
* @param rootCause the <code>Throwable</code> exception
* that interfered with the servlet's
* normal operation, making this servlet
* exception necessary
*
*/
public JspException(String message, Throwable rootCause) {
super(message, rootCause);
}
/**
* Constructs a new JSP exception when the JSP
* needs to throw an exception and include a message
* about the "root cause" exception that interfered with its
* normal operation.
*
*
* @param rootCause the <code>Throwable</code> exception
* that interfered with the JSP's
* normal operation, making the JSP exception
* necessary
*
*/
public JspException(Throwable rootCause) {
super(rootCause);
}
/**
* Returns the exception that caused this JSP exception.
*
*
* @return the <code>Throwable</code>
* that caused this JSP exception
*
*/
public Throwable getRootCause() {
return getCause();
}
}
| 1,257 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/JspContext.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
import java.util.Enumeration;
import javax.el.ELContext;
import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.VariableResolver;
/**
* <p>
* <code>JspContext</code> serves as the base class for the
* PageContext class and abstracts all information that is not specific
* to servlets. This allows for Simple Tag Extensions to be used
* outside of the context of a request/response Servlet.
* <p>
* The JspContext provides a number of facilities to the
* page/component author and page implementor, including:
* <ul>
* <li>a single API to manage the various scoped namespaces
* <li>a mechanism to obtain the JspWriter for output
* <li>a mechanism to expose page directive attributes to the
* scripting environment
* </ul>
*
* <p><B>Methods Intended for Container Generated Code</B>
* <p>
* The following methods enable the <B>management of nested</B> JspWriter
* streams to implement Tag Extensions: <code>pushBody()</code> and
* <code>popBody()</code>
*
* <p><B>Methods Intended for JSP authors</B>
* <p>
* Some methods provide <B>uniform access</B> to the diverse objects
* representing scopes.
* The implementation must use the underlying machinery
* corresponding to that scope, so information can be passed back and
* forth between the underlying environment (e.g. Servlets) and JSP pages.
* The methods are:
* <code>setAttribute()</code>, <code>getAttribute()</code>,
* <code>findAttribute()</code>, <code>removeAttribute()</code>,
* <code>getAttributesScope()</code> and
* <code>getAttributeNamesInScope()</code>.
*
* <p>
* The following methods provide <B>convenient access</B> to implicit objects:
* <code>getOut()</code>
*
* <p>
* The following methods provide <B>programmatic access</b> to the
* Expression Language evaluator:
* <code>getExpressionEvaluator()</code>, <code>getVariableResolver()</code>
*
* @since 2.0
*/
public abstract class JspContext {
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public JspContext() {
}
/**
* Register the name and value specified with page scope semantics.
* If the value passed in is <code>null</code>, this has the same
* effect as calling
* <code>removeAttribute( name, PageContext.PAGE_SCOPE )</code>.
*
* @param name the name of the attribute to set
* @param value the value to associate with the name, or null if the
* attribute is to be removed from the page scope.
* @throws NullPointerException if the name is null
*/
abstract public void setAttribute(String name, Object value);
/**
* Register the name and value specified with appropriate
* scope semantics. If the value passed in is <code>null</code>,
* this has the same effect as calling
* <code>removeAttribute( name, scope )</code>.
*
* @param name the name of the attribute to set
* @param value the object to associate with the name, or null if
* the attribute is to be removed from the specified scope.
* @param scope the scope with which to associate the name/object
*
* @throws NullPointerException if the name is null
* @throws IllegalArgumentException if the scope is invalid
* @throws IllegalStateException if the scope is
* PageContext.SESSION_SCOPE but the page that was requested
* does not participate in a session or the session has been
* invalidated.
*/
abstract public void setAttribute(String name, Object value, int scope);
/**
* Returns the object associated with the name in the page scope or null
* if not found.
*
* @param name the name of the attribute to get
* @return the object associated with the name in the page scope
* or null if not found.
*
* @throws NullPointerException if the name is null
*/
abstract public Object getAttribute(String name);
/**
* Return the object associated with the name in the specified
* scope or null if not found.
*
* @param name the name of the attribute to set
* @param scope the scope with which to associate the name/object
* @return the object associated with the name in the specified
* scope or null if not found.
*
* @throws NullPointerException if the name is null
* @throws IllegalArgumentException if the scope is invalid
* @throws IllegalStateException if the scope is
* PageContext.SESSION_SCOPE but the page that was requested
* does not participate in a session or the session has been
* invalidated.
*/
abstract public Object getAttribute(String name, int scope);
/**
* Searches for the named attribute in page, request, session (if valid),
* and application scope(s) in order and returns the value associated or
* null.
*
* @param name the name of the attribute to search for
* @return the value associated or null
* @throws NullPointerException if the name is null
*/
abstract public Object findAttribute(String name);
/**
* Remove the object reference associated with the given name
* from all scopes. Does nothing if there is no such object.
*
* @param name The name of the object to remove.
* @throws NullPointerException if the name is null
*/
abstract public void removeAttribute(String name);
/**
* Remove the object reference associated with the specified name
* in the given scope. Does nothing if there is no such object.
*
* @param name The name of the object to remove.
* @param scope The scope where to look.
* @throws IllegalArgumentException if the scope is invalid
* @throws IllegalStateException if the scope is
* PageContext.SESSION_SCOPE but the page that was requested
* does not participate in a session or the session has been
* invalidated.
* @throws NullPointerException if the name is null
*/
abstract public void removeAttribute(String name, int scope);
/**
* Get the scope where a given attribute is defined.
*
* @param name the name of the attribute to return the scope for
* @return the scope of the object associated with the name specified or 0
* @throws NullPointerException if the name is null
*/
abstract public int getAttributesScope(String name);
/**
* Enumerate all the attributes in a given scope.
*
* @param scope the scope to enumerate all the attributes for
* @return an enumeration of names (java.lang.String) of all the
* attributes the specified scope
* @throws IllegalArgumentException if the scope is invalid
* @throws IllegalStateException if the scope is
* PageContext.SESSION_SCOPE but the page that was requested
* does not participate in a session or the session has been
* invalidated.
*/
abstract public Enumeration<String> getAttributeNamesInScope(int scope);
/**
* The current value of the out object (a JspWriter).
*
* @return the current JspWriter stream being used for client response
*/
abstract public JspWriter getOut();
/**
* Provides programmatic access to the ExpressionEvaluator.
* The JSP Container must return a valid instance of an
* ExpressionEvaluator that can parse EL expressions.
*
* @return A valid instance of an ExpressionEvaluator.
* @since 2.0
*/
public abstract ExpressionEvaluator getExpressionEvaluator();
public abstract ELContext getELContext();
/**
* Returns an instance of a VariableResolver that provides access to the
* implicit objects specified in the JSP specification using this JspContext
* as the context object.
*
* @return A valid instance of a VariableResolver.
* @since 2.0
*/
public abstract VariableResolver getVariableResolver();
/**
* Return a new JspWriter object that sends output to the
* provided Writer. Saves the current "out" JspWriter,
* and updates the value of the "out" attribute in the
* page scope attribute namespace of the JspContext.
* <p>The returned JspWriter must implement all methods and
* behave as though it were unbuffered. More specifically:
* <ul>
* <li>clear() must throw an IOException</li>
* <li>clearBuffer() does nothing</li>
* <li>getBufferSize() always returns 0</li>
* <li>getRemaining() always returns 0</li>
* </ul>
* </p>
*
* @param writer The Writer for the returned JspWriter to send
* output to.
* @return a new JspWriter that writes to the given Writer.
* @since 2.0
*/
public JspWriter pushBody( java.io.Writer writer ) {
return null; // XXX to implement
}
/**
* Return the previous JspWriter "out" saved by the matching
* pushBody(), and update the value of the "out" attribute in
* the page scope attribute namespace of the JspContext.
*
* @return the saved JspWriter.
*/
public JspWriter popBody() {
return null; // XXX to implement
}
}
| 1,258 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/JspFactory.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.jsp.PageContext;
/**
* <p>
* The JspFactory is an abstract class that defines a number of factory
* methods available to a JSP page at runtime for the purposes of creating
* instances of various interfaces and classes used to support the JSP
* implementation.
* <p>
* A conformant JSP Engine implementation will, during it's initialization
* instantiate an implementation dependent subclass of this class, and make
* it globally available for use by JSP implementation classes by registering
* the instance created with this class via the
* static <code> setDefaultFactory() </code> method.
* <p>
* The PageContext and the JspEngineInfo classes are the only implementation-dependent
* classes that can be created from the factory.
* <p>
* JspFactory objects should not be used by JSP page authors.
*/
public abstract class JspFactory {
private static JspFactory deflt = null;
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public JspFactory() {
}
/**
* <p>
* set the default factory for this implementation. It is illegal for
* any principal other than the JSP Engine runtime to call this method.
* </p>
*
* @param deflt The default factory implementation
*/
public static synchronized void setDefaultFactory(JspFactory deflt) {
JspFactory.deflt = deflt;
}
/**
* Returns the default factory for this implementation.
*
* @return the default factory for this implementation
*/
public static synchronized JspFactory getDefaultFactory() {
return deflt;
}
/**
* <p>
* obtains an instance of an implementation dependent
* javax.servlet.jsp.PageContext abstract class for the calling Servlet
* and currently pending request and response.
* </p>
*
* <p>
* This method is typically called early in the processing of the
* _jspService() method of a JSP implementation class in order to
* obtain a PageContext object for the request being processed.
* </p>
* <p>
* Invoking this method shall result in the PageContext.initialize()
* method being invoked. The PageContext returned is properly initialized.
* </p>
* <p>
* All PageContext objects obtained via this method shall be released
* by invoking releasePageContext().
* </p>
*
* @param servlet the requesting servlet
* @param request the current request pending on the servlet
* @param response the current response pending on the servlet
* @param errorPageURL the URL of the error page for the requesting JSP, or null
* @param needsSession true if the JSP participates in a session
* @param buffer size of buffer in bytes, PageContext.NO_BUFFER if no buffer,
* PageContext.DEFAULT_BUFFER if implementation default.
* @param autoflush should the buffer autoflush to the output stream on buffer
* overflow, or throw an IOException?
*
* @return the page context
*
* @see javax.servlet.jsp.PageContext
*/
public abstract PageContext getPageContext(Servlet servlet,
ServletRequest request,
ServletResponse response,
String errorPageURL,
boolean needsSession,
int buffer,
boolean autoflush);
/**
* <p>
* called to release a previously allocated PageContext object.
* Results in PageContext.release() being invoked.
* This method should be invoked prior to returning from the _jspService() method of a JSP implementation
* class.
* </p>
*
* @param pc A PageContext previously obtained by getPageContext()
*/
public abstract void releasePageContext(PageContext pc);
/**
* <p>
* called to get implementation-specific information on the current JSP engine.
* </p>
*
* @return a JspEngineInfo object describing the current JSP engine
*/
public abstract JspEngineInfo getEngineInfo();
/**
* <p>
* Obtain the <code>JspApplicationContext</code> instance that was associated
* within the passed <code>ServletContext</code> for this web application.
* </p>
*
* @param context the current web application's <code>ServletContext</code>
* @return <code>JspApplicationContext</code> instance
* @since 2.1
*/
public abstract JspApplicationContext getJspApplicationContext(ServletContext context);
}
| 1,259 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/ErrorData.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
/**
* Contains information about an error, for error pages.
* The information contained in this instance is meaningless if not used
* in the context of an error page. To indicate a JSP is an error page,
* the page author must set the isErrorPage attribute of the page directive
* to "true".
*
* @see PageContext#getErrorData
* @since 2.0
*/
public final class ErrorData {
private Throwable throwable;
private int statusCode;
private String uri;
private String servletName;
/**
* Creates a new ErrorData object.
*
* @param throwable The Throwable that is the cause of the error
* @param statusCode The status code of the error
* @param uri The request URI
* @param servletName The name of the servlet invoked
*/
public ErrorData( Throwable throwable, int statusCode, String uri,
String servletName )
{
this.throwable = throwable;
this.statusCode = statusCode;
this.uri = uri;
this.servletName = servletName;
}
/**
* Returns the Throwable that caused the error.
*
* @return The Throwable that caused the error
*/
public Throwable getThrowable() {
return this.throwable;
}
/**
* Returns the status code of the error.
*
* @return The status code of the error
*/
public int getStatusCode() {
return this.statusCode;
}
/**
* Returns the request URI.
*
* @return The request URI
*/
public String getRequestURI() {
return this.uri;
}
/**
* Returns the name of the servlet invoked.
*
* @return The name of the servlet invoked
*/
public String getServletName() {
return this.servletName;
}
}
| 1,260 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/SkipPageException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
/**
* Exception to indicate the calling page must cease evaluation.
* Thrown by a simple tag handler to indicate that the remainder of
* the page must not be evaluated. The result is propagated back to
* the pagein the case where one tag invokes another (as can be
* the case with tag files). The effect is similar to that of a
* Classic Tag Handler returning Tag.SKIP_PAGE from doEndTag().
* Jsp Fragments may also throw this exception. This exception
* should not be thrown manually in a JSP page or tag file - the behavior is
* undefined. The exception is intended to be thrown inside
* SimpleTag handlers and in JSP fragments.
*
* @see javax.servlet.jsp.tagext.SimpleTag#doTag
* @see javax.servlet.jsp.tagext.JspFragment#invoke
* @see javax.servlet.jsp.tagext.Tag#doEndTag
* @since 2.0
*/
public class SkipPageException
extends JspException
{
/**
* Creates a SkipPageException with no message.
*/
public SkipPageException() {
super();
}
/**
* Creates a SkipPageException with the provided message.
*
* @param message the detail message
*/
public SkipPageException( String message ) {
super( message );
}
/**
* Creates a SkipPageException with the provided message and root cause.
*
* @param message the detail message
* @param rootCause the originating cause of this exception
*/
public SkipPageException( String message, Throwable rootCause ) {
super( message, rootCause );
}
/**
* Creates a SkipPageException with the provided root cause.
*
* @param rootCause the originating cause of this exception
*/
public SkipPageException( Throwable rootCause ) {
super( rootCause );
}
}
| 1,261 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/PageContext.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp;
import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.tagext.BodyContent;
/**
* <p>
* PageContext extends JspContext to provide useful context information for
* when JSP technology is used in a Servlet environment.
* <p>
* A PageContext instance provides access to all the namespaces associated
* with a JSP page, provides access to several page attributes, as well as
* a layer above the implementation details. Implicit objects are added
* to the pageContext automatically.
*
* <p> The <code> PageContext </code> class is an abstract class, designed to be
* extended to provide implementation dependent implementations thereof, by
* conformant JSP engine runtime environments. A PageContext instance is
* obtained by a JSP implementation class by calling the
* JspFactory.getPageContext() method, and is released by calling
* JspFactory.releasePageContext().
*
* <p> An example of how PageContext, JspFactory, and other classes can be
* used within a JSP Page Implementation object is given elsewhere.
*
* <p>
* The PageContext provides a number of facilities to the page/component
* author and page implementor, including:
* <ul>
* <li>a single API to manage the various scoped namespaces
* <li>a number of convenience API's to access various public objects
* <li>a mechanism to obtain the JspWriter for output
* <li>a mechanism to manage session usage by the page
* <li>a mechanism to expose page directive attributes to the scripting
* environment
* <li>mechanisms to forward or include the current request to other active
* components in the application
* <li>a mechanism to handle errorpage exception processing
* </ul>
*
* <p><B>Methods Intended for Container Generated Code</B>
* <p>Some methods are intended to be used by the code generated by the
* container, not by code written by JSP page authors, or JSP tag library
* authors.
* <p>The methods supporting <B>lifecycle</B> are <code>initialize()</code>
* and <code>release()</code>
*
* <p>
* The following methods enable the <B>management of nested</B> JspWriter
* streams to implement Tag Extensions: <code>pushBody()</code>
*
* <p><B>Methods Intended for JSP authors</B>
* <p>
* The following methods provide <B>convenient access</B> to implicit objects:
* <code>getException()</code>, <code>getPage()</code>
* <code>getRequest()</code>, <code>getResponse()</code>,
* <code>getSession()</code>, <code>getServletConfig()</code>
* and <code>getServletContext()</code>.
*
* <p>
* The following methods provide support for <B>forwarding, inclusion
* and error handling</B>:
* <code>forward()</code>, <code>include()</code>,
* and <code>handlePageException()</code>.
*/
abstract public class PageContext
extends JspContext
{
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public PageContext() {
}
/**
* Page scope: (this is the default) the named reference remains available
* in this PageContext until the return from the current Servlet.service()
* invocation.
*/
public static final int PAGE_SCOPE = 1;
/**
* Request scope: the named reference remains available from the
* ServletRequest associated with the Servlet until the current request
* is completed.
*/
public static final int REQUEST_SCOPE = 2;
/**
* Session scope (only valid if this page participates in a session):
* the named reference remains available from the HttpSession (if any)
* associated with the Servlet until the HttpSession is invalidated.
*/
public static final int SESSION_SCOPE = 3;
/**
* Application scope: named reference remains available in the
* ServletContext until it is reclaimed.
*/
public static final int APPLICATION_SCOPE = 4;
/**
* Name used to store the Servlet in this PageContext's nametables.
*/
public static final String PAGE = "javax.servlet.jsp.jspPage";
/**
* Name used to store this PageContext in it's own name table.
*/
public static final String PAGECONTEXT = "javax.servlet.jsp.jspPageContext";
/**
* Name used to store ServletRequest in PageContext name table.
*/
public static final String REQUEST = "javax.servlet.jsp.jspRequest";
/**
* Name used to store ServletResponse in PageContext name table.
*/
public static final String RESPONSE = "javax.servlet.jsp.jspResponse";
/**
* Name used to store ServletConfig in PageContext name table.
*/
public static final String CONFIG = "javax.servlet.jsp.jspConfig";
/**
* Name used to store HttpSession in PageContext name table.
*/
public static final String SESSION = "javax.servlet.jsp.jspSession";
/**
* Name used to store current JspWriter in PageContext name table.
*/
public static final String OUT = "javax.servlet.jsp.jspOut";
/**
* Name used to store ServletContext in PageContext name table.
*/
public static final String APPLICATION = "javax.servlet.jsp.jspApplication";
/**
* Name used to store uncaught exception in ServletRequest attribute
* list and PageContext name table.
*/
public static final String EXCEPTION = "javax.servlet.jsp.jspException";
/**
* <p>
* The initialize method is called to initialize an uninitialized PageContext
* so that it may be used by a JSP Implementation class to service an
* incoming request and response within it's _jspService() method.
*
* <p>
* This method is typically called from JspFactory.getPageContext() in
* order to initialize state.
*
* <p>
* This method is required to create an initial JspWriter, and associate
* the "out" name in page scope with this newly created object.
*
* <p>
* This method should not be used by page or tag library authors.
*
* @param servlet The Servlet that is associated with this PageContext
* @param request The currently pending request for this Servlet
* @param response The currently pending response for this Servlet
* @param errorPageURL The value of the errorpage attribute from the page
* directive or null
* @param needsSession The value of the session attribute from the
* page directive
* @param bufferSize The value of the buffer attribute from the page
* directive
* @param autoFlush The value of the autoflush attribute from the page
* directive
*
* @throws IOException during creation of JspWriter
* @throws IllegalStateException if out not correctly initialized
* @throws IllegalArgumentException If one of the given parameters
* is invalid
*/
abstract public void initialize(Servlet servlet, ServletRequest request,
ServletResponse response, String errorPageURL, boolean needsSession,
int bufferSize, boolean autoFlush)
throws IOException, IllegalStateException, IllegalArgumentException;
/**
* <p>
* This method shall "reset" the internal state of a PageContext, releasing
* all internal references, and preparing the PageContext for potential
* reuse by a later invocation of initialize(). This method is typically
* called from JspFactory.releasePageContext().
*
* <p>
* Subclasses shall envelope this method.
*
* <p>
* This method should not be used by page or tag library authors.
*
*/
abstract public void release();
/**
* The current value of the session object (an HttpSession).
*
* @return the HttpSession for this PageContext or null
*/
abstract public HttpSession getSession();
/**
* The current value of the page object (In a Servlet environment,
* this is an instance of javax.servlet.Servlet).
*
* @return the Page implementation class instance associated
* with this PageContext
*/
abstract public Object getPage();
/**
* The current value of the request object (a ServletRequest).
*
* @return The ServletRequest for this PageContext
*/
abstract public ServletRequest getRequest();
/**
* The current value of the response object (a ServletResponse).
*
* @return the ServletResponse for this PageContext
*/
abstract public ServletResponse getResponse();
/**
* The current value of the exception object (an Exception).
*
* @return any exception passed to this as an errorpage
*/
abstract public Exception getException();
/**
* The ServletConfig instance.
*
* @return the ServletConfig for this PageContext
*/
abstract public ServletConfig getServletConfig();
/**
* The ServletContext instance.
*
* @return the ServletContext for this PageContext
*/
abstract public ServletContext getServletContext();
/**
* <p>
* This method is used to re-direct, or "forward" the current
* ServletRequest and ServletResponse to another active component in
* the application.
* </p>
* <p>
* If the <I> relativeUrlPath </I> begins with a "/" then the URL specified
* is calculated relative to the DOCROOT of the <code> ServletContext </code>
* for this JSP. If the path does not begin with a "/" then the URL
* specified is calculated relative to the URL of the request that was
* mapped to the calling JSP.
* </p>
* <p>
* It is only valid to call this method from a <code> Thread </code>
* executing within a <code> _jspService(...) </code> method of a JSP.
* </p>
* <p>
* Once this method has been called successfully, it is illegal for the
* calling <code> Thread </code> to attempt to modify the <code>
* ServletResponse </code> object. Any such attempt to do so, shall result
* in undefined behavior. Typically, callers immediately return from
* <code> _jspService(...) </code> after calling this method.
* </p>
*
* @param relativeUrlPath specifies the relative URL path to the target
* resource as described above
*
* @throws IllegalStateException if <code> ServletResponse </code> is not
* in a state where a forward can be performed
* @throws ServletException if the page that was forwarded to throws
* a ServletException
* @throws IOException if an I/O error occurred while forwarding
*/
abstract public void forward(String relativeUrlPath)
throws ServletException, IOException;
/**
* <p>
* Causes the resource specified to be processed as part of the current
* ServletRequest and ServletResponse being processed by the calling Thread.
* The output of the target resources processing of the request is written
* directly to the ServletResponse output stream.
* </p>
* <p>
* The current JspWriter "out" for this JSP is flushed as a side-effect
* of this call, prior to processing the include.
* </p>
* <p>
* If the <I> relativeUrlPath </I> begins with a "/" then the URL specified
* is calculated relative to the DOCROOT of the <code>ServletContext</code>
* for this JSP. If the path does not begin with a "/" then the URL
* specified is calculated relative to the URL of the request that was
* mapped to the calling JSP.
* </p>
* <p>
* It is only valid to call this method from a <code> Thread </code>
* executing within a <code> _jspService(...) </code> method of a JSP.
* </p>
*
* @param relativeUrlPath specifies the relative URL path to the target
* resource to be included
*
* @throws ServletException if the page that was forwarded to throws
* a ServletException
* @throws IOException if an I/O error occurred while forwarding
*/
abstract public void include(String relativeUrlPath)
throws ServletException, IOException;
/**
* <p>
* Causes the resource specified to be processed as part of the current
* ServletRequest and ServletResponse being processed by the calling Thread.
* The output of the target resources processing of the request is written
* directly to the current JspWriter returned by a call to getOut().
* </p>
* <p>
* If flush is true, The current JspWriter "out" for this JSP
* is flushed as a side-effect of this call, prior to processing
* the include. Otherwise, the JspWriter "out" is not flushed.
* </p>
* <p>
* If the <i>relativeUrlPath</i> begins with a "/" then the URL specified
* is calculated relative to the DOCROOT of the <code>ServletContext</code>
* for this JSP. If the path does not begin with a "/" then the URL
* specified is calculated relative to the URL of the request that was
* mapped to the calling JSP.
* </p>
* <p>
* It is only valid to call this method from a <code> Thread </code>
* executing within a <code> _jspService(...) </code> method of a JSP.
* </p>
*
* @param relativeUrlPath specifies the relative URL path to the
* target resource to be included
* @param flush True if the JspWriter is to be flushed before the include,
* or false if not.
*
* @throws ServletException if the page that was forwarded to throws
* a ServletException
* @throws IOException if an I/O error occurred while forwarding
* @since 2.0
*/
abstract public void include(String relativeUrlPath, boolean flush)
throws ServletException, IOException;
/**
* <p>
* This method is intended to process an unhandled 'page' level
* exception by forwarding the exception to the specified
* error page for this JSP. If forwarding is not possible (for
* example because the response has already been committed), an
* implementation dependent mechanism should be used to invoke
* the error page (e.g. "including" the error page instead).
*
* <p>
* If no error page is defined in the page, the exception should
* be rethrown so that the standard servlet error handling
* takes over.
*
* <p>
* A JSP implementation class shall typically clean up any local state
* prior to invoking this and will return immediately thereafter. It is
* illegal to generate any output to the client, or to modify any
* ServletResponse state after invoking this call.
*
* <p>
* This method is kept for backwards compatiblity reasons. Newly
* generated code should use PageContext.handlePageException(Throwable).
*
* @param e the exception to be handled
*
* @throws ServletException if an error occurs while invoking the error page
* @throws IOException if an I/O error occurred while invoking the error
* page
* @throws NullPointerException if the exception is null
*
* @see #handlePageException(Throwable)
*/
abstract public void handlePageException(Exception e)
throws ServletException, IOException;
/**
* <p>
* This method is intended to process an unhandled 'page' level
* exception by forwarding the exception to the specified
* error page for this JSP. If forwarding is not possible (for
* example because the response has already been committed), an
* implementation dependent mechanism should be used to invoke
* the error page (e.g. "including" the error page instead).
*
* <p>
* If no error page is defined in the page, the exception should
* be rethrown so that the standard servlet error handling
* takes over.
*
* <p>
* This method is intended to process an unhandled "page" level exception
* by redirecting the exception to either the specified error page for this
* JSP, or if none was specified, to perform some implementation dependent
* action.
*
* <p>
* A JSP implementation class shall typically clean up any local state
* prior to invoking this and will return immediately thereafter. It is
* illegal to generate any output to the client, or to modify any
* ServletResponse state after invoking this call.
*
* @param t the throwable to be handled
*
* @throws ServletException if an error occurs while invoking the error page
* @throws IOException if an I/O error occurred while invoking the error
* page
* @throws NullPointerException if the exception is null
*
* @see #handlePageException(Exception)
*/
abstract public void handlePageException(Throwable t)
throws ServletException, IOException;
/**
* Return a new BodyContent object, save the current "out" JspWriter,
* and update the value of the "out" attribute in the page scope
* attribute namespace of the PageContext.
*
* @return the new BodyContent
*/
public BodyContent pushBody() {
return null; // XXX to implement
}
/**
* Provides convenient access to error information.
*
* @return an ErrorData instance containing information about the
* error, as obtained from the request attributes, as per the
* Servlet specification. If this is not an error page (that is,
* if the isErrorPage attribute of the page directive is not set
* to "true"), the information is meaningless.
*
* @since 2.0
*/
public ErrorData getErrorData() {
return new ErrorData(
(Throwable)getRequest().getAttribute( "javax.servlet.error.exception" ),
((Integer)getRequest().getAttribute(
"javax.servlet.error.status_code" )).intValue(),
(String)getRequest().getAttribute( "javax.servlet.error.request_uri" ),
(String)getRequest().getAttribute( "javax.servlet.error.servlet_name" ) );
}
}
| 1,262 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/el/ExpressionEvaluator.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
/**
* <p>The abstract base class for an expression-language evaluator.
* Classes that implement an expression language expose their functionality
* via this abstract class.</p>
*
* <p>An instance of the ExpressionEvaluator can be obtained via the
* JspContext / PageContext</p>
*
* <p>The parseExpression() and evaluate() methods must be thread-safe.
* That is, multiple threads may call these methods on the same
* ExpressionEvaluator object simultaneously. Implementations should
* synchronize access if they depend on transient state. Implementations
* should not, however, assume that only one object of each
* ExpressionEvaluator type will be instantiated; global caching should
* therefore be static.</p>
*
* <p>Only a single EL expression, starting with '${' and ending with
* '}', can be parsed or evaluated at a time. EL expressions
* cannot be mixed with static text. For example, attempting to
* parse or evaluate "<code>abc${1+1}def${1+1}ghi</code>" or even
* "<code>${1+1}${1+1}</code>" will cause an <code>ELException</code> to
* be thrown.</p>
*
* <p>The following are examples of syntactically legal EL expressions:
*
* <ul>
* <li><code>${person.lastName}</code></li>
* <li><code>${8 * 8}</code></li>
* <li><code>${my:reverse('hello')}</code></li>
* </ul>
* </p>
*
* @since 2.0
* @deprecated
*/
public abstract class ExpressionEvaluator {
/**
* Prepare an expression for later evaluation. This method should perform
* syntactic validation of the expression; if in doing so it detects
* errors, it should raise an ELParseException.
*
* @param expression The expression to be evaluated.
* @param expectedType The expected type of the result of the evaluation
* @param fMapper A FunctionMapper to resolve functions found in
* the expression. It can be null, in which case no functions
* are supported for this invocation. The ExpressionEvaluator
* must not hold on to the FunctionMapper reference after
* returning from <code>parseExpression()</code>. The
* <code>Expression</code> object returned must invoke the same
* functions regardless of whether the mappings in the
* provided <code>FunctionMapper</code> instance change between
* calling <code>ExpressionEvaluator.parseExpression()</code>
* and <code>Expression.evaluate()</code>.
* @return The Expression object encapsulating the arguments.
*
* @exception ELException Thrown if parsing errors were found.
*/
public abstract Expression parseExpression( String expression,
Class expectedType,
FunctionMapper fMapper )
throws ELException;
/**
* Evaluates an expression. This method may perform some syntactic
* validation and, if so, it should raise an ELParseException error if
* it encounters syntactic errors. EL evaluation errors should cause
* an ELException to be raised.
*
* @param expression The expression to be evaluated.
* @param expectedType The expected type of the result of the evaluation
* @param vResolver A VariableResolver instance that can be used at
* runtime to resolve the name of implicit objects into Objects.
* @param fMapper A FunctionMapper to resolve functions found in
* the expression. It can be null, in which case no functions
* are supported for this invocation.
* @return The result of the expression evaluation.
*
* @exception ELException Thrown if the expression evaluation failed.
*/
public abstract Object evaluate( String expression,
Class expectedType,
VariableResolver vResolver,
FunctionMapper fMapper )
throws ELException;
}
| 1,263 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/el/ScopedAttributeELResolver.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
import java.beans.FeatureDescriptor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.PageContext;
public class ScopedAttributeELResolver extends ELResolver {
public ScopedAttributeELResolver() {
super();
}
public Object getValue(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context
.getContext(JspContext.class);
return page.findAttribute(key);
}
}
return null;
}
public Class<Object> getType(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
return Object.class;
}
return null;
}
public void setValue(ELContext context, Object base, Object property,
Object value) throws NullPointerException,
PropertyNotFoundException, PropertyNotWritableException,
ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
if (property != null) {
String key = property.toString();
PageContext page = (PageContext) context
.getContext(JspContext.class);
int scope = page.getAttributesScope(key);
if (scope != 0) {
page.setAttribute(key, value, scope);
} else {
page.setAttribute(key, value);
}
}
}
}
public boolean isReadOnly(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null) {
context.setPropertyResolved(true);
}
return false;
}
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
PageContext ctxt = (PageContext) context.getContext(JspContext.class);
List<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>();
Enumeration e;
Object value;
String name;
e = ctxt.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
while (e.hasMoreElements()) {
name = (String) e.nextElement();
value = ctxt.getAttribute(name, PageContext.PAGE_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("page scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
e = ctxt.getAttributeNamesInScope(PageContext.REQUEST_SCOPE);
while (e.hasMoreElements()) {
name = (String) e.nextElement();
value = ctxt.getAttribute(name, PageContext.REQUEST_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("request scope attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
if (ctxt.getSession() != null) {
e = ctxt.getAttributeNamesInScope(PageContext.SESSION_SCOPE);
while (e.hasMoreElements()) {
name = (String) e.nextElement();
value = ctxt.getAttribute(name, PageContext.SESSION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("session scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
}
e = ctxt.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
while (e.hasMoreElements()) {
name = (String) e.nextElement();
value = ctxt.getAttribute(name, PageContext.APPLICATION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("application scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
return list.iterator();
}
private static void appendEnumeration(Collection c, Enumeration e) {
while (e.hasMoreElements()) {
c.add(e.nextElement());
}
}
public Class<String> getCommonPropertyType(ELContext context, Object base) {
if (base == null) {
return String.class;
}
return null;
}
}
| 1,264 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/el/ELException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
/**
* Represents any of the exception conditions that arise during the
* operation evaluation of the evaluator.
*
* @since 2.0
* @deprecated
*/
public class ELException
extends Exception
{
//-------------------------------------
// Member variables
//-------------------------------------
private Throwable mRootCause;
//-------------------------------------
/**
* Creates an ELException with no detail message.
**/
public ELException ()
{
super ();
}
//-------------------------------------
/**
* Creates an ELException with the provided detail message.
*
* @param pMessage the detail message
**/
public ELException (String pMessage)
{
super (pMessage);
}
//-------------------------------------
/**
* Creates an ELException with the given root cause.
*
* @param pRootCause the originating cause of this exception
**/
public ELException (Throwable pRootCause)
{
super( pRootCause.getLocalizedMessage() );
mRootCause = pRootCause;
}
//-------------------------------------
/**
* Creates an ELException with the given detail message and root cause.
*
* @param pMessage the detail message
* @param pRootCause the originating cause of this exception
**/
public ELException (String pMessage,
Throwable pRootCause)
{
super (pMessage);
mRootCause = pRootCause;
}
//-------------------------------------
/**
* Returns the root cause.
*
* @return the root cause of this exception
*/
public Throwable getRootCause ()
{
return mRootCause;
}
}
| 1,265 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/el/Expression.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
/**
* <p>The abstract class for a prepared expression.</p>
*
* <p>An instance of an Expression can be obtained via from an
* ExpressionEvaluator instance.</p>
*
* <p>An Expression may or not have done a syntactic parse of the expression.
* A client invoking the evaluate() method should be ready for the case
* where ELParseException exceptions are raised. </p>
*
* @since 2.0
* @deprecated
*/
public abstract class Expression {
/**
* Evaluates an expression that was previously prepared. In some
* implementations preparing an expression involves full syntactic
* validation, but others may not do so. Evaluating the expression may
* raise an ELParseException as well as other ELExceptions due to
* run-time evaluation.
*
* @param vResolver A VariableResolver instance that can be used at
* runtime to resolve the name of implicit objects into Objects.
* @return The result of the expression evaluation.
*
* @exception ELException Thrown if the expression evaluation failed.
*/
public abstract Object evaluate( VariableResolver vResolver )
throws ELException;
}
| 1,266 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/el/FunctionMapper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
/**
* <p>The interface to a map between EL function names and methods.</p>
*
* <p>Classes implementing this interface may, for instance, consult tag library
* information to resolve the map. </p>
*
* @since 2.0
* @deprecated
*/
public interface FunctionMapper {
/**
* Resolves the specified local name and prefix into a Java.lang.Method.
* Returns null if the prefix and local name are not found.
*
* @param prefix the prefix of the function, or "" if no prefix.
* @param localName the short name of the function
* @return the result of the method mapping. Null means no entry found.
**/
public java.lang.reflect.Method resolveFunction(String prefix,
String localName);
}
| 1,267 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/el/ELParseException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
/**
* Represents a parsing error encountered while parsing an EL expression.
*
* @since 2.0
* @deprecated
*/
public class ELParseException extends ELException {
//-------------------------------------
/**
* Creates an ELParseException with no detail message.
*/
public ELParseException ()
{
super ();
}
//-------------------------------------
/**
* Creates an ELParseException with the provided detail message.
*
* @param pMessage the detail message
**/
public ELParseException (String pMessage)
{
super (pMessage);
}
//-------------------------------------
}
| 1,268 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/el/ImplicitObjectELResolver.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
import java.beans.FeatureDescriptor;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.PageContext;
/**
*
* @since 2.1
*/
public class ImplicitObjectELResolver extends ELResolver {
private enum Scope {
APPLICATIONSCOPE("applicationScope"),
COOKIE("cookie"),
HEADER("header"),
HEADERVALUES("headerValues"),
INITPARAM("initParam"),
PAGECONTEXT("pageContext"),
PAGESCOPE("pageScope"),
PARAM("param"),
PARAM_VALUES("paramValues"),
REQUEST_SCOPE("requestScope"),
SESSION_SCOPE("sessionScope");
private final String name;
private Scope(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
private final static Map<String, Scope> SCOPE_MAP = new HashMap<String, Scope>();
static {
for (Scope scope : Scope.values()) {
SCOPE_MAP.put(scope.toString(), scope);
}
}
public ImplicitObjectELResolver() {
super();
}
public Object getValue(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null && property != null) {
Scope scope = SCOPE_MAP.get(property.toString());
if (scope != null) {
PageContext page = (PageContext) context
.getContext(JspContext.class);
context.setPropertyResolved(true);
switch (scope) {
case APPLICATIONSCOPE:
return ScopeManager.get(page).getApplicationScope();
case COOKIE:
return ScopeManager.get(page).getCookie();
case HEADER:
return ScopeManager.get(page).getHeader();
case HEADERVALUES:
return ScopeManager.get(page).getHeaderValues();
case INITPARAM:
return ScopeManager.get(page).getInitParam();
case PAGECONTEXT:
return ScopeManager.get(page).getPageContext();
case PAGESCOPE:
return ScopeManager.get(page).getPageScope();
case PARAM:
return ScopeManager.get(page).getParam();
case PARAM_VALUES:
return ScopeManager.get(page).getParamValues();
case REQUEST_SCOPE:
return ScopeManager.get(page).getRequestScope();
case SESSION_SCOPE:
return ScopeManager.get(page).getSessionScope();
}
}
}
return null;
}
public Class getType(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null && property != null) {
Scope scope = SCOPE_MAP.get(property.toString());
if (scope != null) {
context.setPropertyResolved(true);
}
}
return null;
}
public void setValue(ELContext context, Object base, Object property,
Object value) throws NullPointerException,
PropertyNotFoundException, PropertyNotWritableException,
ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null && property != null) {
Scope scope = SCOPE_MAP.get(property.toString());
if (scope != null) {
context.setPropertyResolved(true);
throw new PropertyNotWritableException();
}
}
}
public boolean isReadOnly(ELContext context, Object base, Object property)
throws NullPointerException, PropertyNotFoundException, ELException {
if (context == null) {
throw new NullPointerException();
}
if (base == null && property != null) {
Scope scope = SCOPE_MAP.get(property.toString());
if (scope != null) {
context.setPropertyResolved(true);
return true;
}
}
return false;
}
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
Scope[] scopes = Scope.values();
List<FeatureDescriptor> feats = new ArrayList<FeatureDescriptor>(scopes.length);
FeatureDescriptor feat;
for (int i = 0; i < scopes.length; i++) {
feat = new FeatureDescriptor();
feat.setDisplayName(scopes[i].toString());
feat.setExpert(false);
feat.setHidden(false);
feat.setName(scopes[i].toString());
feat.setPreferred(true);
feat.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
feat.setValue(TYPE, String.class);
feats.add(feat);
}
return feats.iterator();
}
public Class<String> getCommonPropertyType(ELContext context, Object base) {
if (base == null) {
return String.class;
}
return null;
}
private static class ScopeManager {
private final static String MNGR_KEY = ScopeManager.class.getName();
private final PageContext page;
private Map applicationScope;
private Map cookie;
private Map header;
private Map headerValues;
private Map initParam;
private Map pageScope;
private Map param;
private Map paramValues;
private Map requestScope;
private Map sessionScope;
public ScopeManager(PageContext page) {
this.page = page;
}
public static ScopeManager get(PageContext page) {
ScopeManager mngr = (ScopeManager) page.getAttribute(MNGR_KEY);
if (mngr == null) {
mngr = new ScopeManager(page);
page.setAttribute(MNGR_KEY, mngr);
}
return mngr;
}
public Map getApplicationScope() {
if (this.applicationScope == null) {
this.applicationScope = new ScopeMap() {
protected void setAttribute(String name, Object value) {
page.getServletContext().setAttribute(name, value);
}
protected void removeAttribute(String name) {
page.getServletContext().removeAttribute(name);
}
protected Enumeration getAttributeNames() {
return page.getServletContext().getAttributeNames();
}
protected Object getAttribute(String name) {
return page.getServletContext().getAttribute(name);
}
};
}
return this.applicationScope;
}
public Map getCookie() {
if (this.cookie == null) {
this.cookie = new ScopeMap() {
protected Enumeration getAttributeNames() {
Cookie[] c = ((HttpServletRequest) page.getRequest())
.getCookies();
if (c != null) {
Vector v = new Vector();
for (int i = 0; i < c.length; i++) {
v.add(c[i].getName());
}
return v.elements();
}
return null;
}
protected Object getAttribute(String name) {
Cookie[] c = ((HttpServletRequest) page.getRequest())
.getCookies();
if (c != null) {
for (int i = 0; i < c.length; i++) {
if (name.equals(c[i].getName())) {
return c[i];
}
}
}
return null;
}
};
}
return this.cookie;
}
public Map getHeader() {
if (this.header == null) {
this.header = new ScopeMap() {
protected Enumeration getAttributeNames() {
return ((HttpServletRequest) page.getRequest())
.getHeaderNames();
}
protected Object getAttribute(String name) {
return ((HttpServletRequest) page.getRequest())
.getHeader(name);
}
};
}
return this.header;
}
public Map getHeaderValues() {
if (this.headerValues == null) {
this.headerValues = new ScopeMap() {
protected Enumeration getAttributeNames() {
return ((HttpServletRequest) page.getRequest())
.getHeaderNames();
}
protected Object getAttribute(String name) {
Enumeration e = ((HttpServletRequest) page.getRequest())
.getHeaders(name);
if (e != null) {
List list = new ArrayList();
while (e.hasMoreElements()) {
list.add(e.nextElement().toString());
}
return (String[]) list.toArray(new String[list
.size()]);
}
return null;
}
};
}
return this.headerValues;
}
public Map getInitParam() {
if (this.initParam == null) {
this.initParam = new ScopeMap() {
protected Enumeration getAttributeNames() {
return page.getServletContext().getInitParameterNames();
}
protected Object getAttribute(String name) {
return page.getServletContext().getInitParameter(name);
}
};
}
return this.initParam;
}
public PageContext getPageContext() {
return this.page;
}
public Map getPageScope() {
if (this.pageScope == null) {
this.pageScope = new ScopeMap() {
protected void setAttribute(String name, Object value) {
page.setAttribute(name, value);
}
protected void removeAttribute(String name) {
page.removeAttribute(name);
}
protected Enumeration getAttributeNames() {
return page
.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
}
protected Object getAttribute(String name) {
return page.getAttribute(name);
}
};
}
return this.pageScope;
}
public Map getParam() {
if (this.param == null) {
this.param = new ScopeMap() {
protected Enumeration getAttributeNames() {
return page.getRequest().getParameterNames();
}
protected Object getAttribute(String name) {
return page.getRequest().getParameter(name);
}
};
}
return this.param;
}
public Map getParamValues() {
if (this.paramValues == null) {
this.paramValues = new ScopeMap() {
protected Object getAttribute(String name) {
return page.getRequest().getParameterValues(name);
}
protected Enumeration getAttributeNames() {
return page.getRequest().getParameterNames();
}
};
}
return this.paramValues;
}
public Map getRequestScope() {
if (this.requestScope == null) {
this.requestScope = new ScopeMap() {
protected void setAttribute(String name, Object value) {
page.getRequest().setAttribute(name, value);
}
protected void removeAttribute(String name) {
page.getRequest().removeAttribute(name);
}
protected Enumeration getAttributeNames() {
return page.getRequest().getAttributeNames();
}
protected Object getAttribute(String name) {
return page.getRequest().getAttribute(name);
}
};
}
return this.requestScope;
}
public Map getSessionScope() {
if (this.sessionScope == null) {
this.sessionScope = new ScopeMap() {
protected void setAttribute(String name, Object value) {
((HttpServletRequest) page.getRequest()).getSession()
.setAttribute(name, value);
}
protected void removeAttribute(String name) {
HttpSession session = page.getSession();
if (session != null) {
session.removeAttribute(name);
}
}
protected Enumeration getAttributeNames() {
HttpSession session = page.getSession();
if (session != null) {
return session.getAttributeNames();
}
return null;
}
protected Object getAttribute(String name) {
HttpSession session = page.getSession();
if (session != null) {
return session.getAttribute(name);
}
return null;
}
};
}
return this.sessionScope;
}
}
private abstract static class ScopeMap extends AbstractMap {
protected abstract Enumeration getAttributeNames();
protected abstract Object getAttribute(String name);
protected void removeAttribute(String name) {
throw new UnsupportedOperationException();
}
protected void setAttribute(String name, Object value) {
throw new UnsupportedOperationException();
}
public final Set entrySet() {
Enumeration e = getAttributeNames();
Set set = new HashSet();
if (e != null) {
while (e.hasMoreElements()) {
set.add(new ScopeEntry((String) e.nextElement()));
}
}
return set;
}
private class ScopeEntry implements Map.Entry {
private final String key;
public ScopeEntry(String key) {
this.key = key;
}
public Object getKey() {
return (Object) this.key;
}
public Object getValue() {
return getAttribute(this.key);
}
public Object setValue(Object value) {
if (value == null) {
removeAttribute(this.key);
} else {
setAttribute(this.key, value);
}
return null;
}
public boolean equals(Object obj) {
return (obj != null && this.hashCode() == obj.hashCode());
}
public int hashCode() {
return this.key.hashCode();
}
}
public final Object get(Object key) {
if (key != null) {
return getAttribute(key.toString());
}
return null;
}
public final Object put(Object key, Object value) {
if (key == null) {
throw new NullPointerException();
}
if (value == null) {
this.removeAttribute(key.toString());
} else {
this.setAttribute(key.toString(), value);
}
return null;
}
public final Object remove(Object key) {
if (key == null) {
throw new NullPointerException();
}
this.removeAttribute(key.toString());
return null;
}
}
}
| 1,269 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/el/VariableResolver.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
/**
* <p>This class is used to customize the way an ExpressionEvaluator resolves
* variable references at evaluation time. For example, instances of this class can
* implement their own variable lookup mechanisms, or introduce the
* notion of "implicit variables" which override any other variables.
* An instance of this class should be passed when evaluating
* an expression.</p>
*
* <p>An instance of this class includes the context against which resolution
* will happen</p>
*
* @since 2.0
* @deprecated
*/
public interface VariableResolver
{
//-------------------------------------
/**
* Resolves the specified variable.
* Returns null if the variable is not found.
*
* @param pName the name of the variable to resolve
* @return the result of the variable resolution
*
* @throws ELException if a failure occurred while trying to resolve
* the given variable
**/
public Object resolveVariable (String pName)
throws ELException;
//-------------------------------------
}
| 1,270 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagVariableInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* Variable information for a tag in a Tag Library;
* This class is instantiated from the Tag Library Descriptor file (TLD)
* and is available only at translation time.
*
* This object should be immutable.
*
* This information is only available in JSP 1.2 format TLDs or above.
*/
public class TagVariableInfo {
/**
* Constructor for TagVariableInfo.
*
* @param nameGiven value of <name-given>
* @param nameFromAttribute value of <name-from-attribute>
* @param className value of <variable-class>
* @param declare value of <declare>
* @param scope value of <scope>
*/
public TagVariableInfo(
String nameGiven,
String nameFromAttribute,
String className,
boolean declare,
int scope) {
this.nameGiven = nameGiven;
this.nameFromAttribute = nameFromAttribute;
this.className = className;
this.declare = declare;
this.scope = scope;
}
/**
* The body of the <name-given> element.
*
* @return The variable name as a constant
*/
public String getNameGiven() {
return nameGiven;
}
/**
* The body of the <name-from-attribute> element.
* This is the name of an attribute whose (translation-time)
* value will give the name of the variable. One of
* <name-given> or <name-from-attribute> is required.
*
* @return The attribute whose value defines the variable name
*/
public String getNameFromAttribute() {
return nameFromAttribute;
}
/**
* The body of the <variable-class> element.
*
* @return The name of the class of the variable or
* 'java.lang.String' if not defined in the TLD.
*/
public String getClassName() {
return className;
}
/**
* The body of the <declare> element.
*
* @return Whether the variable is to be declared or not.
* If not defined in the TLD, 'true' will be returned.
*/
public boolean getDeclare() {
return declare;
}
/**
* The body of the <scope> element.
*
* @return The scope to give the variable. NESTED
* scope will be returned if not defined in
* the TLD.
*/
public int getScope() {
return scope;
}
/*
* private fields
*/
private String nameGiven; // <name-given>
private String nameFromAttribute; // <name-from-attribute>
private String className; // <class>
private boolean declare; // <declare>
private int scope; // <scope>
}
| 1,271 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/FunctionInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* Information for a function in a Tag Library.
* This class is instantiated from the Tag Library Descriptor file (TLD)
* and is available only at translation time.
*
* @since 2.0
*/
public class FunctionInfo {
/**
* Constructor for FunctionInfo.
*
* @param name The name of the function
* @param klass The class of the function
* @param signature The signature of the function
*/
public FunctionInfo(String name, String klass, String signature) {
this.name = name;
this.functionClass = klass;
this.functionSignature = signature;
}
/**
* The name of the function.
*
* @return The name of the function
*/
public String getName() {
return name;
}
/**
* The class of the function.
*
* @return The class of the function
*/
public String getFunctionClass() {
return functionClass;
}
/**
* The signature of the function.
*
* @return The signature of the function
*/
public String getFunctionSignature() {
return functionSignature;
}
/*
* fields
*/
private String name;
private String functionClass;
private String functionSignature;
}
| 1,272 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagFileInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* Tag information for a tag file in a Tag Library;
* This class is instantiated from the Tag Library Descriptor file (TLD)
* and is available only at translation time.
*
* @since 2.0
*/
public class TagFileInfo {
/**
* Constructor for TagFileInfo from data in the JSP 2.0 format for TLD.
* This class is to be instantiated only from the TagLibrary code
* under request from some JSP code that is parsing a
* TLD (Tag Library Descriptor).
*
* Note that, since TagLibraryInfo reflects both TLD information
* and taglib directive information, a TagFileInfo instance is
* dependent on a taglib directive. This is probably a
* design error, which may be fixed in the future.
*
* @param name The unique action name of this tag
* @param path Where to find the .tag file implementing this
* action, relative to the location of the TLD file.
* @param tagInfo The detailed information about this tag, as parsed
* from the directives in the tag file.
*/
public TagFileInfo( String name, String path, TagInfo tagInfo ) {
this.name = name;
this.path = path;
this.tagInfo = tagInfo;
}
/**
* The unique action name of this tag.
*
* @return The (short) name of the tag.
*/
public String getName() {
return name;
}
/**
* Where to find the .tag file implementing this action.
*
* @return The path of the tag file, relative to the TLD, or "." if
* the tag file was defined in an implicit tag file.
*/
public String getPath() {
return path;
}
/**
* Returns information about this tag, parsed from the directives
* in the tag file.
*
* @return a TagInfo object containing information about this tag
*/
public TagInfo getTagInfo() {
return tagInfo;
}
// private fields for 2.0 info
private String name;
private String path;
private TagInfo tagInfo;
}
| 1,273 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagLibraryInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.tagext.TagInfo;
import javax.servlet.jsp.tagext.TagFileInfo;
/**
* Translation-time information associated with a taglib directive, and its
* underlying TLD file.
*
* Most of the information is directly from the TLD, except for
* the prefix and the uri values used in the taglib directive
*
*
*/
abstract public class TagLibraryInfo {
/**
* Constructor.
*
* This will invoke the constructors for TagInfo, and TagAttributeInfo
* after parsing the TLD file.
*
* @param prefix the prefix actually used by the taglib directive
* @param uri the URI actually used by the taglib directive
*/
protected TagLibraryInfo(String prefix, String uri) {
this.prefix = prefix;
this.uri = uri;
}
// ==== methods accessing taglib information =======
/**
* The value of the uri attribute from the taglib directive for
* this library.
*
* @return the value of the uri attribute
*/
public String getURI() {
return uri;
}
/**
* The prefix assigned to this taglib from the taglib directive
*
* @return the prefix assigned to this taglib from the taglib directive
*/
public String getPrefixString() {
return prefix;
}
// ==== methods using the TLD data =======
/**
* The preferred short name (prefix) as indicated in the TLD.
* This may be used by authoring tools as the preferred prefix
* to use when creating an taglib directive for this library.
*
* @return the preferred short name for the library
*/
public String getShortName() {
return shortname;
}
/**
* The "reliable" URN indicated in the TLD (the uri element).
* This may be used by authoring tools as a global identifier
* to use when creating a taglib directive for this library.
*
* @return a reliable URN to a TLD like this
*/
public String getReliableURN() {
return urn;
}
/**
* Information (documentation) for this TLD.
*
* @return the info string for this tag lib
*/
public String getInfoString() {
return info;
}
/**
* A string describing the required version of the JSP container.
*
* @return the (minimal) required version of the JSP container.
* @see javax.servlet.jsp.JspEngineInfo
*/
public String getRequiredVersion() {
return jspversion;
}
/**
* An array describing the tags that are defined in this tag library.
*
* @return the TagInfo objects corresponding to the tags defined by this
* tag library, or a zero length array if this tag library
* defines no tags
*/
public TagInfo[] getTags() {
return tags;
}
/**
* An array describing the tag files that are defined in this tag library.
*
* @return the TagFileInfo objects corresponding to the tag files defined
* by this tag library, or a zero length array if this
* tag library defines no tags files
* @since 2.0
*/
public TagFileInfo[] getTagFiles() {
return tagFiles;
}
/**
* Get the TagInfo for a given tag name, looking through all the
* tags in this tag library.
*
* @param shortname The short name (no prefix) of the tag
* @return the TagInfo for the tag with the specified short name, or
* null if no such tag is found
*/
public TagInfo getTag(String shortname) {
TagInfo tags[] = getTags();
if (tags == null || tags.length == 0) {
return null;
}
for (int i=0; i < tags.length; i++) {
if (tags[i].getTagName().equals(shortname)) {
return tags[i];
}
}
return null;
}
/**
* Get the TagFileInfo for a given tag name, looking through all the
* tag files in this tag library.
*
* @param shortname The short name (no prefix) of the tag
* @return the TagFileInfo for the specified Tag file, or null
* if no Tag file is found
* @since 2.0
*/
public TagFileInfo getTagFile(String shortname) {
TagFileInfo tagFiles[] = getTagFiles();
if (tagFiles == null || tagFiles.length == 0) {
return null;
}
for (int i=0; i < tagFiles.length; i++) {
if (tagFiles[i].getName().equals(shortname)) {
return tagFiles[i];
}
}
return null;
}
/**
* An array describing the functions that are defined in this tag library.
*
* @return the functions defined in this tag library, or a zero
* length array if the tag library defines no functions.
* @since 2.0
*/
public FunctionInfo[] getFunctions() {
return functions;
}
/**
* Get the FunctionInfo for a given function name, looking through all the
* functions in this tag library.
*
* @param name The name (no prefix) of the function
* @return the FunctionInfo for the function with the given name, or null
* if no such function exists
* @since 2.0
*/
public FunctionInfo getFunction(String name) {
if (functions == null || functions.length == 0) {
System.err.println("No functions");
return null;
}
for (int i=0; i < functions.length; i++) {
if (functions[i].getName().equals(name)) {
return functions[i];
}
}
return null;
}
/**
* Returns an array of TagLibraryInfo objects representing the entire set
* of tag libraries (including this TagLibraryInfo) imported by taglib
* directives in the translation unit that references this TagLibraryInfo.
* If a tag library is imported more than once and bound to different prefices,
* only the TagLibraryInfo bound to the first prefix must be included
* in the returned array.
*
* @return Array of TagLibraryInfo objects representing the entire set
* of tag libraries (including this TagLibraryInfo) imported by taglib
* directives in the translation unit that references this TagLibraryInfo.
* @since 2.1
*/
public abstract javax.servlet.jsp.tagext.TagLibraryInfo[] getTagLibraryInfos();
// Protected fields
/**
* The prefix assigned to this taglib from the taglib directive.
*/
protected String prefix;
/**
* The value of the uri attribute from the taglib directive for
* this library.
*/
protected String uri;
/**
* An array describing the tags that are defined in this tag library.
*/
protected TagInfo[] tags;
/**
* An array describing the tag files that are defined in this tag library.
*
* @since 2.0
*/
protected TagFileInfo[] tagFiles;
/**
* An array describing the functions that are defined in this tag library.
*
* @since 2.0
*/
protected FunctionInfo[] functions;
// Tag Library Data
/**
* The version of the tag library.
*/
protected String tlibversion; // required
/**
* The version of the JSP specification this tag library is written to.
*/
protected String jspversion; // required
/**
* The preferred short name (prefix) as indicated in the TLD.
*/
protected String shortname; // required
/**
* The "reliable" URN indicated in the TLD.
*/
protected String urn; // required
/**
* Information (documentation) for this TLD.
*/
protected String info; // optional
}
| 1,274 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/JspIdConsumer.java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
public interface JspIdConsumer {
public void setJspId(String jspId);
}
| 1,275 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagAdapter.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.*;
/**
* Wraps any SimpleTag and exposes it using a Tag interface. This is used
* to allow collaboration between classic Tag handlers and SimpleTag
* handlers.
* <p>
* Because SimpleTag does not extend Tag, and because Tag.setParent()
* only accepts a Tag instance, a classic tag handler (one
* that implements Tag) cannot have a SimpleTag as its parent. To remedy
* this, a TagAdapter is created to wrap the SimpleTag parent, and the
* adapter is passed to setParent() instead. A classic Tag Handler can
* call getAdaptee() to retrieve the encapsulated SimpleTag instance.
*
* @since 2.0
*/
public class TagAdapter
implements Tag
{
/** The simple tag that's being adapted. */
private SimpleTag simpleTagAdaptee;
/** The parent, of this tag, converted (if necessary) to be of type Tag. */
private Tag parent;
// Flag indicating whether we have already determined the parent
private boolean parentDetermined;
/**
* Creates a new TagAdapter that wraps the given SimpleTag and
* returns the parent tag when getParent() is called.
*
* @param adaptee The SimpleTag being adapted as a Tag.
*/
public TagAdapter( SimpleTag adaptee ) {
if( adaptee == null ) {
// Cannot wrap a null adaptee.
throw new IllegalArgumentException();
}
this.simpleTagAdaptee = adaptee;
}
/**
* Must not be called.
*
* @param pc ignored.
* @throws UnsupportedOperationException Must not be called
*/
public void setPageContext(PageContext pc) {
throw new UnsupportedOperationException(
"Illegal to invoke setPageContext() on TagAdapter wrapper" );
}
/**
* Must not be called. The parent of this tag is always
* getAdaptee().getParent().
*
* @param parentTag ignored.
* @throws UnsupportedOperationException Must not be called.
*/
public void setParent( Tag parentTag ) {
throw new UnsupportedOperationException(
"Illegal to invoke setParent() on TagAdapter wrapper" );
}
/**
* Returns the parent of this tag, which is always
* getAdaptee().getParent().
*
* This will either be the enclosing Tag (if getAdaptee().getParent()
* implements Tag), or an adapter to the enclosing Tag (if
* getAdaptee().getParent() does not implement Tag).
*
* @return The parent of the tag being adapted.
*/
public Tag getParent() {
if (!parentDetermined) {
JspTag adapteeParent = simpleTagAdaptee.getParent();
if (adapteeParent != null) {
if (adapteeParent instanceof Tag) {
this.parent = (Tag) adapteeParent;
} else {
// Must be SimpleTag - no other types defined.
this.parent = new TagAdapter((SimpleTag) adapteeParent);
}
}
parentDetermined = true;
}
return this.parent;
}
/**
* Gets the tag that is being adapted to the Tag interface.
* This should be an instance of SimpleTag in JSP 2.0, but room
* is left for other kinds of tags in future spec versions.
*
* @return the tag that is being adapted
*/
public JspTag getAdaptee() {
return this.simpleTagAdaptee;
}
/**
* Must not be called.
*
* @return always throws UnsupportedOperationException
* @throws UnsupportedOperationException Must not be called
* @throws JspException never thrown
*/
public int doStartTag() throws JspException {
throw new UnsupportedOperationException(
"Illegal to invoke doStartTag() on TagAdapter wrapper" );
}
/**
* Must not be called.
*
* @return always throws UnsupportedOperationException
* @throws UnsupportedOperationException Must not be called
* @throws JspException never thrown
*/
public int doEndTag() throws JspException {
throw new UnsupportedOperationException(
"Illegal to invoke doEndTag() on TagAdapter wrapper" );
}
/**
* Must not be called.
*
* @throws UnsupportedOperationException Must not be called
*/
public void release() {
throw new UnsupportedOperationException(
"Illegal to invoke release() on TagAdapter wrapper" );
}
}
| 1,276 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/PageData.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import java.io.InputStream;
/**
* Translation-time information on a JSP page. The information
* corresponds to the XML view of the JSP page.
*
* <p>
* Objects of this type are generated by the JSP translator, e.g.
* when being pased to a TagLibraryValidator instance.
*/
abstract public class PageData {
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public PageData() {
}
/**
* Returns an input stream on the XML view of a JSP page.
* The stream is encoded in UTF-8. Recall tht the XML view of a
* JSP page has the include directives expanded.
*
* @return An input stream on the document.
*/
abstract public InputStream getInputStream();
}
| 1,277 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagAttributeInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* Information on the attributes of a Tag, available at translation time. This
* class is instantiated from the Tag Library Descriptor file (TLD).
*
* <p>
* Only the information needed to generate code is included here. Other
* information like SCHEMA for validation belongs elsewhere.
*/
public class TagAttributeInfo {
/**
* "id" is wired in to be ID. There is no real benefit in having it be
* something else IDREFs are not handled any differently.
*/
public static final String ID = "id";
/**
* Constructor for TagAttributeInfo. This class is to be instantiated only
* from the TagLibrary code under request from some JSP code that is parsing
* a TLD (Tag Library Descriptor).
*
* @param name
* The name of the attribute.
* @param required
* If this attribute is required in tag instances.
* @param type
* The name of the type of the attribute.
* @param reqTime
* Whether this attribute holds a request-time Attribute.
*/
public TagAttributeInfo(String name, boolean required, String type,
boolean reqTime) {
this.name = name;
this.required = required;
this.type = type;
this.reqTime = reqTime;
}
/**
* JSP 2.0 Constructor for TagAttributeInfo. This class is to be
* instantiated only from the TagLibrary code under request from some JSP
* code that is parsing a TLD (Tag Library Descriptor).
*
* @param name
* The name of the attribute.
* @param required
* If this attribute is required in tag instances.
* @param type
* The name of the type of the attribute.
* @param reqTime
* Whether this attribute holds a request-time Attribute.
* @param fragment
* Whether this attribute is of type JspFragment
*
* @since 2.0
*/
public TagAttributeInfo(String name, boolean required, String type,
boolean reqTime, boolean fragment) {
this(name, required, type, reqTime);
this.fragment = fragment;
}
/**
* @since JSP 2.1
*/
public TagAttributeInfo(String name, boolean required, String type,
boolean reqTime, boolean fragment, String description,
boolean deferredValue, boolean deferredMethod,
String expectedTypeName, String methodSignature) {
this(name, required, type, reqTime, fragment);
this.description = description;
this.deferredValue = deferredValue;
this.deferredMethod = deferredMethod;
this.expectedTypeName = expectedTypeName;
this.methodSignature = methodSignature;
}
/**
* The name of this attribute.
*
* @return the name of the attribute
*/
public String getName() {
return name;
}
/**
* The type (as a String) of this attribute.
*
* @return the type of the attribute
*/
public String getTypeName() {
return type;
}
/**
* Whether this attribute can hold a request-time value.
*
* @return if the attribute can hold a request-time value.
*/
public boolean canBeRequestTime() {
return reqTime;
}
/**
* Whether this attribute is required.
*
* @return if the attribute is required.
*/
public boolean isRequired() {
return required;
}
/**
* Convenience static method that goes through an array of TagAttributeInfo
* objects and looks for "id".
*
* @param a
* An array of TagAttributeInfo
* @return The TagAttributeInfo reference with name "id"
*/
public static TagAttributeInfo getIdAttribute(TagAttributeInfo a[]) {
for (int i = 0; i < a.length; i++) {
if (a[i].getName().equals(ID)) {
return a[i];
}
}
return null; // no such attribute
}
/**
* Whether this attribute is of type JspFragment.
*
* @return if the attribute is of type JspFragment
*
* @since 2.0
*/
public boolean isFragment() {
return fragment;
}
/**
* Returns a String representation of this TagAttributeInfo, suitable for
* debugging purposes.
*
* @return a String representation of this TagAttributeInfo
*/
public String toString() {
StringBuffer b = new StringBuffer(64);
b.append("name = " + name + " ");
b.append("type = " + type + " ");
b.append("reqTime = " + reqTime + " ");
b.append("required = " + required + " ");
b.append("fragment = " + fragment + " ");
b.append("deferredValue = " + deferredValue + " ");
b.append("expectedTypeName = " + expectedTypeName + " ");
b.append("deferredMethod = " + deferredMethod + " ");
b.append("methodSignature = " + methodSignature);
return b.toString();
}
/*
* private fields
*/
private String name;
private String type;
private boolean reqTime;
private boolean required;
/*
* private fields for JSP 2.0
*/
private boolean fragment;
/*
* private fields for JSP 2.1
*/
private String description;
private boolean deferredValue;
private boolean deferredMethod;
private String expectedTypeName;
private String methodSignature;
public boolean isDeferredMethod() {
return deferredMethod;
}
public boolean isDeferredValue() {
return deferredValue;
}
public String getDescription() {
return description;
}
public String getExpectedTypeName() {
return expectedTypeName;
}
public String getMethodSignature() {
return methodSignature;
}
}
| 1,278 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/SimpleTagSupport.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import java.io.IOException;
/**
* A base class for defining tag handlers implementing SimpleTag.
* <p>
* The SimpleTagSupport class is a utility class intended to be used
* as the base class for new simple tag handlers. The SimpleTagSupport
* class implements the SimpleTag interface and adds additional
* convenience methods including getter methods for the properties in
* SimpleTag.
*
* @since 2.0
*/
public class SimpleTagSupport
implements SimpleTag
{
/** Reference to the enclosing tag. */
private JspTag parentTag;
/** The JSP context for the upcoming tag invocation. */
private JspContext jspContext;
/** The body of the tag. */
private JspFragment jspBody;
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public SimpleTagSupport() {
}
/**
* Default processing of the tag does nothing.
*
* @throws JspException Subclasses can throw JspException to indicate
* an error occurred while processing this tag.
* @throws javax.servlet.jsp.SkipPageException If the page that
* (either directly or indirectly) invoked this tag is to
* cease evaluation. A Simple Tag Handler generated from a
* tag file must throw this exception if an invoked Classic
* Tag Handler returned SKIP_PAGE or if an invoked Simple
* Tag Handler threw SkipPageException or if an invoked Jsp Fragment
* threw a SkipPageException.
* @throws IOException Subclasses can throw IOException if there was
* an error writing to the output stream
* @see SimpleTag#doTag()
*/
public void doTag()
throws JspException, IOException
{
}
/**
* Sets the parent of this tag, for collaboration purposes.
* <p>
* The container invokes this method only if this tag invocation is
* nested within another tag invocation.
*
* @param parent the tag that encloses this tag
*/
public void setParent( JspTag parent ) {
this.parentTag = parent;
}
/**
* Returns the parent of this tag, for collaboration purposes.
*
* @return the parent of this tag
*/
public JspTag getParent() {
return this.parentTag;
}
/**
* Stores the provided JSP context in the private jspContext field.
* Subclasses can access the <code>JspContext</code> via
* <code>getJspContext()</code>.
*
* @param pc the page context for this invocation
* @see SimpleTag#setJspContext
*/
public void setJspContext( JspContext pc ) {
this.jspContext = pc;
}
/**
* Returns the page context passed in by the container via
* setJspContext.
*
* @return the page context for this invocation
*/
protected JspContext getJspContext() {
return this.jspContext;
}
/**
* Stores the provided JspFragment.
*
* @param jspBody The fragment encapsulating the body of this tag.
* If the action element is empty in the page, this method is
* not called at all.
* @see SimpleTag#setJspBody
*/
public void setJspBody( JspFragment jspBody ) {
this.jspBody = jspBody;
}
/**
* Returns the body passed in by the container via setJspBody.
*
* @return the fragment encapsulating the body of this tag, or
* null if the action element is empty in the page.
*/
protected JspFragment getJspBody() {
return this.jspBody;
}
/**
* Find the instance of a given class type that is closest to a given
* instance.
* This method uses the getParent method from the Tag and/or SimpleTag
* interfaces. This method is used for coordination among
* cooperating tags.
*
* <p> For every instance of TagAdapter
* encountered while traversing the ancestors, the tag handler returned by
* <tt>TagAdapter.getAdaptee()</tt> - instead of the TagAdpater itself -
* is compared to <tt>klass</tt>. If the tag handler matches, it - and
* not its TagAdapter - is returned.
*
* <p>
* The current version of the specification only provides one formal
* way of indicating the observable type of a tag handler: its
* tag handler implementation class, described in the tag-class
* subelement of the tag element. This is extended in an
* informal manner by allowing the tag library author to
* indicate in the description subelement an observable type.
* The type should be a subtype of the tag handler implementation
* class or void.
* This addititional constraint can be exploited by a
* specialized container that knows about that specific tag library,
* as in the case of the JSP standard tag library.
*
* <p>
* When a tag library author provides information on the
* observable type of a tag handler, client programmatic code
* should adhere to that constraint. Specifically, the Class
* passed to findAncestorWithClass should be a subtype of the
* observable type.
*
*
* @param from The instance from where to start looking.
* @param klass The subclass of JspTag or interface to be matched
* @return the nearest ancestor that implements the interface
* or is an instance of the class specified
*/
public static final JspTag findAncestorWithClass(
JspTag from, Class<?> klass)
{
boolean isInterface = false;
if (from == null || klass == null
|| (!JspTag.class.isAssignableFrom(klass)
&& !(isInterface = klass.isInterface()))) {
return null;
}
for (;;) {
JspTag parent = null;
if( from instanceof SimpleTag ) {
parent = ((SimpleTag)from).getParent();
}
else if( from instanceof Tag ) {
parent = ((Tag)from).getParent();
}
if (parent == null) {
return null;
}
if (parent instanceof TagAdapter) {
parent = ((TagAdapter) parent).getAdaptee();
}
if ((isInterface && klass.isInstance(parent))
|| klass.isAssignableFrom(parent.getClass())) {
return parent;
}
from = parent;
}
}
}
| 1,279 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/Tag.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.*;
/**
* The interface of a classic tag handler that does not want to manipulate
* its body. The Tag interface defines the basic protocol between a Tag
* handler and JSP page implementation class. It defines the life cycle
* and the methods to be invoked at start and end tag.
*
* <p><B>Properties</B></p>
*
* <p>The Tag interface specifies the setter and getter methods for the core
* pageContext and parent properties.</p>
*
* <p>The JSP page implementation object invokes setPageContext and
* setParent, in that order, before invoking doStartTag() or doEndTag().</p>
*
* <p><B>Methods</B></p>
*
* <p>There are two main actions: doStartTag and doEndTag. Once all
* appropriate properties have been initialized, the doStartTag and
* doEndTag methods can be invoked on the tag handler. Between these
* invocations, the tag handler is assumed to hold a state that must
* be preserved. After the doEndTag invocation, the tag handler is
* available for further invocations (and it is expected to have
* retained its properties).</p>
*
* <p><B>Lifecycle</B></p>
*
* <p>Lifecycle details are described by the transition diagram below,
* with the following comments:
* <ul>
* <li> [1] This transition is intended to be for releasing long-term data.
* no guarantees are assumed on whether any properties have been retained
* or not.
* <li> [2] This transition happens if and only if the tag ends normally
* without raising an exception
* <li> [3] Some setters may be called again before a tag handler is
* reused. For instance, <code>setParent()</code> is called if it's
* reused within the same page but at a different level,
* <code>setPageContext()</code> is called if it's used in another page,
* and attribute setters are called if the values differ or are expressed
* as request-time attribute values.
* <li> Check the TryCatchFinally interface for additional details related
* to exception handling and resource management.
* </ul></p>
*
* <IMG src="doc-files/TagProtocol.gif"
* alt="Lifecycle Details Transition Diagram for Tag"/>
*
* <p>Once all invocations on the tag handler
* are completed, the release method is invoked on it. Once a release
* method is invoked <em>all</em> properties, including parent and
* pageContext, are assumed to have been reset to an unspecified value.
* The page compiler guarantees that release() will be invoked on the Tag
* handler before the handler is released to the GC.</p>
*
* <p><B>Empty and Non-Empty Action</B></p>
* <p>If the TagLibraryDescriptor file indicates that the action must
* always have an empty action, by an <body-content> entry of "empty",
* then the doStartTag() method must return SKIP_BODY.</p>
*
* <p>Otherwise, the doStartTag() method may return SKIP_BODY or
* EVAL_BODY_INCLUDE.</p>
*
* <p>If SKIP_BODY is returned the body, if present, is not evaluated.</p>
*
* <p>If EVAL_BODY_INCLUDE is returned, the body is evaluated and
* "passed through" to the current out.</p>
*/
public interface Tag extends JspTag {
/**
* Skip body evaluation.
* Valid return value for doStartTag and doAfterBody.
*/
public final static int SKIP_BODY = 0;
/**
* Evaluate body into existing out stream.
* Valid return value for doStartTag.
*/
public final static int EVAL_BODY_INCLUDE = 1;
/**
* Skip the rest of the page.
* Valid return value for doEndTag.
*/
public final static int SKIP_PAGE = 5;
/**
* Continue evaluating the page.
* Valid return value for doEndTag().
*/
public final static int EVAL_PAGE = 6;
// Setters for Tag handler data
/**
* Set the current page context.
* This method is invoked by the JSP page implementation object
* prior to doStartTag().
* <p>
* This value is *not* reset by doEndTag() and must be explicitly reset
* by a page implementation if it changes between calls to doStartTag().
*
* @param pc The page context for this tag handler.
*/
void setPageContext(PageContext pc);
/**
* Set the parent (closest enclosing tag handler) of this tag handler.
* Invoked by the JSP page implementation object prior to doStartTag().
* <p>
* This value is *not* reset by doEndTag() and must be explicitly reset
* by a page implementation.
*
* @param t The parent tag, or null.
*/
void setParent(Tag t);
/**
* Get the parent (closest enclosing tag handler) for this tag handler.
*
* <p>
* The getParent() method can be used to navigate the nested tag
* handler structure at runtime for cooperation among custom actions;
* for example, the findAncestorWithClass() method in TagSupport
* provides a convenient way of doing this.
*
* <p>
* The current version of the specification only provides one formal
* way of indicating the observable type of a tag handler: its
* tag handler implementation class, described in the tag-class
* subelement of the tag element. This is extended in an
* informal manner by allowing the tag library author to
* indicate in the description subelement an observable type.
* The type should be a subtype of the tag handler implementation
* class or void.
* This addititional constraint can be exploited by a
* specialized container that knows about that specific tag library,
* as in the case of the JSP standard tag library.
*
* @return the current parent, or null if none.
* @see TagSupport#findAncestorWithClass
*/
Tag getParent();
// Actions for basic start/end processing.
/**
* Process the start tag for this instance.
* This method is invoked by the JSP page implementation object.
*
* <p>
* The doStartTag method assumes that the properties pageContext and
* parent have been set. It also assumes that any properties exposed as
* attributes have been set too. When this method is invoked, the body
* has not yet been evaluated.
*
* <p>
* This method returns Tag.EVAL_BODY_INCLUDE or
* BodyTag.EVAL_BODY_BUFFERED to indicate
* that the body of the action should be evaluated or SKIP_BODY to
* indicate otherwise.
*
* <p>
* When a Tag returns EVAL_BODY_INCLUDE the result of evaluating
* the body (if any) is included into the current "out" JspWriter as it
* happens and then doEndTag() is invoked.
*
* <p>
* BodyTag.EVAL_BODY_BUFFERED is only valid if the tag handler
* implements BodyTag.
*
* <p>
* The JSP container will resynchronize the values of any AT_BEGIN and
* NESTED variables (defined by the associated TagExtraInfo or TLD)
* after the invocation of doStartTag(), except for a tag handler
* implementing BodyTag whose doStartTag() method returns
* BodyTag.EVAL_BODY_BUFFERED.
*
* @return EVAL_BODY_INCLUDE if the tag wants to process body, SKIP_BODY
* if it does not want to process it.
* @throws JspException if an error occurred while processing this tag
* @see BodyTag
*/
int doStartTag() throws JspException;
/**
* Process the end tag for this instance.
* This method is invoked by the JSP page implementation object
* on all Tag handlers.
*
* <p>
* This method will be called after returning from doStartTag. The
* body of the action may or may not have been evaluated, depending on
* the return value of doStartTag.
*
* <p>
* If this method returns EVAL_PAGE, the rest of the page continues
* to be evaluated. If this method returns SKIP_PAGE, the rest of
* the page is not evaluated, the request is completed, and
* the doEndTag() methods of enclosing tags are not invoked. If this
* request was forwarded or included from another page (or Servlet),
* only the current page evaluation is stopped.
*
* <p>
* The JSP container will resynchronize the values of any AT_BEGIN and
* AT_END variables (defined by the associated TagExtraInfo or TLD)
* after the invocation of doEndTag().
*
* @return indication of whether to continue evaluating the JSP page.
* @throws JspException if an error occurred while processing this tag
*/
int doEndTag() throws JspException;
/**
* Called on a Tag handler to release state.
* The page compiler guarantees that JSP page implementation
* objects will invoke this method on all tag handlers,
* but there may be multiple invocations on doStartTag and doEndTag in between.
*/
void release();
}
| 1,280 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagExtraInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* Optional class provided by the tag library author to describe additional
* translation-time information not described in the TLD.
* The TagExtraInfo class is mentioned in the Tag Library Descriptor file (TLD).
*
* <p>
* This class can be used:
* <ul>
* <li> to indicate that the tag defines scripting variables
* <li> to perform translation-time validation of the tag attributes.
* </ul>
*
* <p>
* It is the responsibility of the JSP translator that the initial value
* to be returned by calls to getTagInfo() corresponds to a TagInfo
* object for the tag being translated. If an explicit call to
* setTagInfo() is done, then the object passed will be returned in
* subsequent calls to getTagInfo().
*
* <p>
* The only way to affect the value returned by getTagInfo()
* is through a setTagInfo() call, and thus, TagExtraInfo.setTagInfo() is
* to be called by the JSP translator, with a TagInfo object that
* corresponds to the tag being translated. The call should happen before
* any invocation on validate() and before any invocation on
* getVariableInfo().
*
* <p>
* <tt>NOTE:</tt> It is a (translation time) error for a tag definition
* in a TLD with one or more variable subelements to have an associated
* TagExtraInfo implementation that returns a VariableInfo array with
* one or more elements from a call to getVariableInfo().
*/
public abstract class TagExtraInfo {
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public TagExtraInfo() {
}
/**
* information on scripting variables defined by the tag associated with
* this TagExtraInfo instance.
* Request-time attributes are indicated as such in the TagData parameter.
*
* @param data The TagData instance.
* @return An array of VariableInfo data, or null or a zero length array
* if no scripting variables are to be defined.
*/
public VariableInfo[] getVariableInfo(TagData data) {
return ZERO_VARIABLE_INFO;
}
/**
* Translation-time validation of the attributes.
* Request-time attributes are indicated as such in the TagData parameter.
* Note that the preferred way to do validation is with the validate()
* method, since it can return more detailed information.
*
* @param data The TagData instance.
* @return Whether this tag instance is valid.
* @see TagExtraInfo#validate
*/
public boolean isValid(TagData data) {
return true;
}
/**
* Translation-time validation of the attributes.
* Request-time attributes are indicated as such in the TagData parameter.
* Because of the higher quality validation messages possible,
* this is the preferred way to do validation (although isValid()
* still works).
*
* <p>JSP 2.0 and higher containers call validate() instead of isValid().
* The default implementation of this method is to call isValid(). If
* isValid() returns false, a generic ValidationMessage[] is returned
* indicating isValid() returned false.</p>
*
* @param data The TagData instance.
* @return A null object, or zero length array if no errors, an
* array of ValidationMessages otherwise.
* @since 2.0
*/
public ValidationMessage[] validate( TagData data ) {
ValidationMessage[] result = null;
if( !isValid( data ) ) {
result = new ValidationMessage[] {
new ValidationMessage( data.getId(), "isValid() == false" ) };
}
return result;
}
/**
* Set the TagInfo for this class.
*
* @param tagInfo The TagInfo this instance is extending
*/
public final void setTagInfo(TagInfo tagInfo) {
this.tagInfo = tagInfo;
}
/**
* Get the TagInfo for this class.
*
* @return the taginfo instance this instance is extending
*/
public final TagInfo getTagInfo() {
return tagInfo;
}
// private data
private TagInfo tagInfo;
// zero length VariableInfo array
private static final VariableInfo[] ZERO_VARIABLE_INFO = { };
}
| 1,281 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/VariableInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* Information on the scripting variables that are created/modified by
* a tag (at run-time). This information is provided by TagExtraInfo
* classes and it is used by the translation phase of JSP.
*
* <p>
* Scripting variables generated by a custom action have an associated
* scope of either AT_BEGIN, NESTED, or AT_END.
*
* <p>
* The class name (VariableInfo.getClassName) in the returned objects
* is used to determine the types of the scripting variables.
* Note that because scripting variables are assigned their values
* from scoped attributes which cannot be of primitive types,
* "boxed" types such as <code>java.lang.Integer</code> must
* be used instead of primitives.
*
* <p>
* The class name may be a Fully Qualified Class Name, or a short
* class name.
*
* <p>
* If a Fully Qualified Class Name is provided, it should refer to a
* class that should be in the CLASSPATH for the Web Application (see
* Servlet 2.4 specification - essentially it is WEB-INF/lib and
* WEB-INF/classes). Failure to be so will lead to a translation-time
* error.
*
* <p>
* If a short class name is given in the VariableInfo objects, then
* the class name must be that of a public class in the context of the
* import directives of the page where the custom action appears.
* The class must also be in the CLASSPATH for the Web Application
* (see Servlet 2.4 specification - essentially it is WEB-INF/lib and
* WEB-INF/classes). Failure to be so will lead to a translation-time
* error.
*
* <p><B>Usage Comments</B>
* <p>
* Frequently a fully qualified class name will refer to a class that
* is known to the tag library and thus, delivered in the same JAR
* file as the tag handlers. In most other remaining cases it will
* refer to a class that is in the platform on which the JSP processor
* is built (like J2EE). Using fully qualified class names in this
* manner makes the usage relatively resistant to configuration
* errors.
*
* <p>
* A short name is usually generated by the tag library based on some
* attributes passed through from the custom action user (the author),
* and it is thus less robust: for instance a missing import directive
* in the referring JSP page will lead to an invalid short name class
* and a translation error.
*
* <p><B>Synchronization Protocol</B>
*
* <p>
* The result of the invocation on getVariableInfo is an array of
* VariableInfo objects. Each such object describes a scripting
* variable by providing its name, its type, whether the variable is
* new or not, and what its scope is. Scope is best described through
* a picture:
*
* <p>
* <IMG src="doc-files/VariableInfo-1.gif"
* alt="NESTED, AT_BEGIN and AT_END Variable Scopes"/>
*
*<p>
* The JSP 2.0 specification defines the interpretation of 3 values:
*
* <ul>
* <li> NESTED, if the scripting variable is available between
* the start tag and the end tag of the action that defines it.
* <li>
* AT_BEGIN, if the scripting variable is available from the start tag
* of the action that defines it until the end of the scope.
* <li> AT_END, if the scripting variable is available after the end tag
* of the action that defines it until the end of the scope.
* </ul>
*
* The scope value for a variable implies what methods may affect its
* value and thus where synchronization is needed as illustrated by
* the table below. <b>Note:</b> the synchronization of the variable(s)
* will occur <em>after</em> the respective method has been called.
*
* <blockquote>
* <table cellpadding="2" cellspacing="2" border="0" width="55%"
* bgcolor="#999999" summary="Variable Synchronization Points">
* <tbody>
* <tr align="center">
* <td valign="top" colspan="6" bgcolor="#999999"><u><b>Variable Synchronization
* Points</b></u><br>
* </td>
* </tr>
* <tr>
* <th valign="top" bgcolor="#c0c0c0"> </th>
* <th valign="top" bgcolor="#c0c0c0" align="center">doStartTag()</th>
* <th valign="top" bgcolor="#c0c0c0" align="center">doInitBody()</th>
* <th valign="top" bgcolor="#c0c0c0" align="center">doAfterBody()</th>
* <th valign="top" bgcolor="#c0c0c0" align="center">doEndTag()</th>
* <th valign="top" bgcolor="#c0c0c0" align="center">doTag()</th>
* </tr>
* <tr>
* <td valign="top" bgcolor="#c0c0c0"><b>Tag<br>
* </b></td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, AT_END<br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* </tr>
* <tr>
* <td valign="top" bgcolor="#c0c0c0"><b>IterationTag<br>
* </b></td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, AT_END<br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* </tr>
* <tr>
* <td valign="top" bgcolor="#c0c0c0"><b>BodyTag<br>
* </b></td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<sup>1</sup><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<sup>1</sup><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, NESTED<br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, AT_END<br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* </tr>
* <tr>
* <td valign="top" bgcolor="#c0c0c0"><b>SimpleTag<br>
* </b></td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff"><br>
* </td>
* <td valign="top" align="center" bgcolor="#ffffff">AT_BEGIN, AT_END<br>
* </td>
* </tr>
* </tbody>
* </table>
* <sup>1</sup> Called after <code>doStartTag()</code> if
* <code>EVAL_BODY_INCLUDE</code> is returned, or after
* <code>doInitBody()</code> otherwise.
* </blockquote>
*
* <p><B>Variable Information in the TLD</B>
* <p>
* Scripting variable information can also be encoded directly for most cases
* into the Tag Library Descriptor using the <variable> subelement of the
* <tag> element. See the JSP specification.
*/
public class VariableInfo {
/**
* Scope information that scripting variable is visible only within the
* start/end tags.
*/
public static final int NESTED = 0;
/**
* Scope information that scripting variable is visible after start tag.
*/
public static final int AT_BEGIN = 1;
/**
* Scope information that scripting variable is visible after end tag.
*/
public static final int AT_END = 2;
/**
* Constructor
* These objects can be created (at translation time) by the TagExtraInfo
* instances.
*
* @param varName The name of the scripting variable
* @param className The type of this variable
* @param declare If true, it is a new variable (in some languages this will
* require a declaration)
* @param scope Indication on the lexical scope of the variable
*/
public VariableInfo(String varName,
String className,
boolean declare,
int scope) {
this.varName = varName;
this.className = className;
this.declare = declare;
this.scope = scope;
}
// Accessor methods
/**
* Returns the name of the scripting variable.
*
* @return the name of the scripting variable
*/
public String getVarName() {
return varName;
}
/**
* Returns the type of this variable.
*
* @return the type of this variable
*/
public String getClassName() {
return className;
}
/**
* Returns whether this is a new variable.
* If so, in some languages this will require a declaration.
*
* @return whether this is a new variable.
*/
public boolean getDeclare() {
return declare;
}
/**
* Returns the lexical scope of the variable.
*
* @return the lexical scope of the variable, either AT_BEGIN, AT_END,
* or NESTED.
* @see #AT_BEGIN
* @see #AT_END
* @see #NESTED
*/
public int getScope() {
return scope;
}
// == private data
private String varName;
private String className;
private boolean declare;
private int scope;
}
| 1,282 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/BodyContent.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import java.io.Reader;
import java.io.Writer;
import java.io.IOException;
import javax.servlet.jsp.*;
/**
* An encapsulation of the evaluation of the body of an action so it is
* available to a tag handler. BodyContent is a subclass of JspWriter.
*
* <p>
* Note that the content of BodyContent is the result of evaluation, so
* it will not contain actions and the like, but the result of their
* invocation.
*
* <p>
* BodyContent has methods to convert its contents into
* a String, to read its contents, and to clear the contents.
*
* <p>
* The buffer size of a BodyContent object is unbounded. A
* BodyContent object cannot be in autoFlush mode. It is not possible to
* invoke flush on a BodyContent object, as there is no backing stream.
*
* <p>
* Instances of BodyContent are created by invoking the pushBody and
* popBody methods of the PageContext class. A BodyContent is enclosed
* within another JspWriter (maybe another BodyContent object) following
* the structure of their associated actions.
*
* <p>
* A BodyContent is made available to a BodyTag through a setBodyContent()
* call. The tag handler can use the object until after the call to
* doEndTag().
*/
public abstract class BodyContent extends JspWriter {
/**
* Protected constructor.
*
* Unbounded buffer, no autoflushing.
*
* @param e the enclosing JspWriter
*/
protected BodyContent(JspWriter e) {
super(UNBOUNDED_BUFFER , false);
this.enclosingWriter = e;
}
/**
* Redefined flush() so it is not legal.
*
* <p>
* It is not valid to flush a BodyContent because there is no backing
* stream behind it.
*
* @throws IOException always thrown
*/
public void flush() throws IOException {
throw new IOException("Illegal to flush within a custom tag");
}
/**
* Clear the body without throwing any exceptions.
*/
public void clearBody() {
try {
this.clear();
} catch (IOException ex) {
// TODO -- clean this one up.
throw new Error("internal error!;");
}
}
/**
* Return the value of this BodyContent as a Reader.
*
* @return the value of this BodyContent as a Reader
*/
public abstract Reader getReader();
/**
* Return the value of the BodyContent as a String.
*
* @return the value of the BodyContent as a String
*/
public abstract String getString();
/**
* Write the contents of this BodyContent into a Writer.
* Subclasses may optimize common invocation patterns.
*
* @param out The writer into which to place the contents of
* this body evaluation
* @throws IOException if an I/O error occurred while writing the
* contents of this BodyContent to the given Writer
*/
public abstract void writeOut(Writer out) throws IOException;
/**
* Get the enclosing JspWriter.
*
* @return the enclosing JspWriter passed at construction time
*/
public JspWriter getEnclosingWriter() {
return enclosingWriter;
}
// private fields
private JspWriter enclosingWriter;
}
| 1,283 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/SimpleTag.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.JspContext;
/**
* Interface for defining Simple Tag Handlers.
*
* <p>Simple Tag Handlers differ from Classic Tag Handlers in that instead
* of supporting <code>doStartTag()</code> and <code>doEndTag()</code>,
* the <code>SimpleTag</code> interface provides a simple
* <code>doTag()</code> method, which is called once and only once for any
* given tag invocation. All tag logic, iteration, body evaluations, etc.
* are to be performed in this single method. Thus, simple tag handlers
* have the equivalent power of <code>BodyTag</code>, but with a much
* simpler lifecycle and interface.</p>
*
* <p>To support body content, the <code>setJspBody()</code>
* method is provided. The container invokes the <code>setJspBody()</code>
* method with a <code>JspFragment</code> object encapsulating the body of
* the tag. The tag handler implementation can call
* <code>invoke()</code> on that fragment to evaluate the body as
* many times as it needs.</p>
*
* <p>A SimpleTag handler must have a public no-args constructor. Most
* SimpleTag handlers should extend SimpleTagSupport.</p>
*
* <p><b>Lifecycle</b></p>
*
* <p>The following is a non-normative, brief overview of the
* SimpleTag lifecycle. Refer to the JSP Specification for details.</p>
*
* <ol>
* <li>A new tag handler instance is created each time by the container
* by calling the provided zero-args constructor. Unlike classic
* tag handlers, simple tag handlers are never cached and reused by
* the JSP container.</li>
* <li>The <code>setJspContext()</code> and <code>setParent()</code>
* methods are called by the container. The <code>setParent()</code>
* method is only called if the element is nested within another tag
* invocation.</li>
* <li>The setters for each attribute defined for this tag are called
* by the container.</li>
* <li>If a body exists, the <code>setJspBody()</code> method is called
* by the container to set the body of this tag, as a
* <code>JspFragment</code>. If the action element is empty in
* the page, this method is not called at all.</li>
* <li>The <code>doTag()</code> method is called by the container. All
* tag logic, iteration, body evaluations, etc. occur in this
* method.</li>
* <li>The <code>doTag()</code> method returns and all variables are
* synchronized.</li>
* </ol>
*
* @see SimpleTagSupport
* @since 2.0
*/
public interface SimpleTag extends JspTag {
/**
* Called by the container to invoke this tag.
* The implementation of this method is provided by the tag library
* developer, and handles all tag processing, body iteration, etc.
*
* <p>
* The JSP container will resynchronize any AT_BEGIN and AT_END
* variables (defined by the associated tag file, TagExtraInfo, or TLD)
* after the invocation of doTag().
*
* @throws javax.servlet.jsp.JspException If an error occurred
* while processing this tag.
* @throws javax.servlet.jsp.SkipPageException If the page that
* (either directly or indirectly) invoked this tag is to
* cease evaluation. A Simple Tag Handler generated from a
* tag file must throw this exception if an invoked Classic
* Tag Handler returned SKIP_PAGE or if an invoked Simple
* Tag Handler threw SkipPageException or if an invoked Jsp Fragment
* threw a SkipPageException.
* @throws java.io.IOException If there was an error writing to the
* output stream.
*/
public void doTag()
throws javax.servlet.jsp.JspException, java.io.IOException;
/**
* Sets the parent of this tag, for collaboration purposes.
* <p>
* The container invokes this method only if this tag invocation is
* nested within another tag invocation.
*
* @param parent the tag that encloses this tag
*/
public void setParent( JspTag parent );
/**
* Returns the parent of this tag, for collaboration purposes.
*
* @return the parent of this tag
*/
public JspTag getParent();
/**
* Called by the container to provide this tag handler with
* the <code>JspContext</code> for this invocation.
* An implementation should save this value.
*
* @param pc the page context for this invocation
* @see Tag#setPageContext
*/
public void setJspContext( JspContext pc );
/**
* Provides the body of this tag as a JspFragment object, able to be
* invoked zero or more times by the tag handler.
* <p>
* This method is invoked by the JSP page implementation
* object prior to <code>doTag()</code>. If the action element is
* empty in the page, this method is not called at all.
*
* @param jspBody The fragment encapsulating the body of this tag.
*/
public void setJspBody( JspFragment jspBody );
}
| 1,284 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/JspTag.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* Serves as a base class for Tag and SimpleTag.
* This is mostly for organizational and type-safety purposes.
*
* @since 2.0
*/
public interface JspTag {
}
| 1,285 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TryCatchFinally.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* The auxiliary interface of a Tag, IterationTag or BodyTag tag
* handler that wants additional hooks for managing resources.
*
* <p>This interface provides two new methods: doCatch(Throwable)
* and doFinally(). The prototypical invocation is as follows:
*
* <pre>
* h = get a Tag(); // get a tag handler, perhaps from pool
*
* h.setPageContext(pc); // initialize as desired
* h.setParent(null);
* h.setFoo("foo");
*
* // tag invocation protocol; see Tag.java
* try {
* doStartTag()...
* ....
* doEndTag()...
* } catch (Throwable t) {
* // react to exceptional condition
* h.doCatch(t);
* } finally {
* // restore data invariants and release per-invocation resources
* h.doFinally();
* }
*
* ... other invocations perhaps with some new setters
* ...
* h.release(); // release long-term resources
* </pre>
*/
public interface TryCatchFinally {
/**
* Invoked if a Throwable occurs while evaluating the BODY
* inside a tag or in any of the following methods:
* Tag.doStartTag(), Tag.doEndTag(),
* IterationTag.doAfterBody() and BodyTag.doInitBody().
*
* <p>This method is not invoked if the Throwable occurs during
* one of the setter methods.
*
* <p>This method may throw an exception (the same or a new one)
* that will be propagated further up the nest chain. If an exception
* is thrown, doFinally() will be invoked.
*
* <p>This method is intended to be used to respond to an exceptional
* condition.
*
* @param t The throwable exception navigating through this tag.
* @throws Throwable if the exception is to be rethrown further up
* the nest chain.
*/
void doCatch(Throwable t) throws Throwable;
/**
* Invoked in all cases after doEndTag() for any class implementing
* Tag, IterationTag or BodyTag. This method is invoked even if
* an exception has occurred in the BODY of the tag,
* or in any of the following methods:
* Tag.doStartTag(), Tag.doEndTag(),
* IterationTag.doAfterBody() and BodyTag.doInitBody().
*
* <p>This method is not invoked if the Throwable occurs during
* one of the setter methods.
*
* <p>This method should not throw an Exception.
*
* <p>This method is intended to maintain per-invocation data
* integrity and resource management actions.
*/
void doFinally();
}
| 1,286 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/BodyTag.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.*;
/**
* The BodyTag interface extends IterationTag by defining additional
* methods that let a tag handler manipulate the content of evaluating its body.
*
* <p>
* It is the responsibility of the tag handler to manipulate the body
* content. For example the tag handler may take the body content,
* convert it into a String using the bodyContent.getString
* method and then use it. Or the tag handler may take the body
* content and write it out into its enclosing JspWriter using
* the bodyContent.writeOut method.
*
* <p> A tag handler that implements BodyTag is treated as one that
* implements IterationTag, except that the doStartTag method can
* return SKIP_BODY, EVAL_BODY_INCLUDE or EVAL_BODY_BUFFERED.
*
* <p>
* If EVAL_BODY_INCLUDE is returned, then evaluation happens
* as in IterationTag.
*
* <p>
* If EVAL_BODY_BUFFERED is returned, then a BodyContent object will be
* created (by code generated by the JSP compiler) to capture the body
* evaluation.
* The code generated by the JSP compiler obtains the BodyContent object by
* calling the pushBody method of the current pageContext, which
* additionally has the effect of saving the previous out value.
* The page compiler returns this object by calling the popBody
* method of the PageContext class;
* the call also restores the value of out.
*
* <p>
* The interface provides one new property with a setter method and one
* new action method.
*
* <p><B>Properties</B>
* <p> There is a new property: bodyContent, to contain the BodyContent
* object, where the JSP Page implementation object will place the
* evaluation (and reevaluation, if appropriate) of the body. The setter
* method (setBodyContent) will only be invoked if doStartTag() returns
* EVAL_BODY_BUFFERED and the corresponding action element does not have
* an empty body.
*
* <p><B>Methods</B>
* <p> In addition to the setter method for the bodyContent property, there
* is a new action method: doInitBody(), which is invoked right after
* setBodyContent() and before the body evaluation. This method is only
* invoked if doStartTag() returns EVAL_BODY_BUFFERED.
*
* <p><B>Lifecycle</B>
* <p> Lifecycle details are described by the transition diagram below.
* Exceptions that are thrown during the computation of doStartTag(),
* setBodyContent(), doInitBody(), BODY, doAfterBody() interrupt the
* execution sequence and are propagated up the stack, unless the
* tag handler implements the TryCatchFinally interface; see that
* interface for details.
* <p>
* <IMG src="doc-files/BodyTagProtocol.gif"
* alt="Lifecycle Details Transition Diagram for BodyTag"/>
*
* <p><B>Empty and Non-Empty Action</B>
* <p> If the TagLibraryDescriptor file indicates that the action must
* always have an empty element body, by an <body-content> entry
* of "empty", then the doStartTag() method must return SKIP_BODY.
* Otherwise, the doStartTag() method may return SKIP_BODY,
* EVAL_BODY_INCLUDE, or EVAL_BODY_BUFFERED.
*
* <p>Note that which methods are invoked after the doStartTag() depends on
* both the return value and on if the custom action element is empty
* or not in the JSP page, not how it's declared in the TLD.
*
* <p>
* If SKIP_BODY is returned the body is not evaluated, and doEndTag() is
* invoked.
*
* <p>
* If EVAL_BODY_INCLUDE is returned, and the custom action element is not
* empty, setBodyContent() is not invoked,
* doInitBody() is not invoked, the body is evaluated and
* "passed through" to the current out, doAfterBody() is invoked
* and then, after zero or more iterations, doEndTag() is invoked.
* If the custom action element is empty, only doStart() and
* doEndTag() are invoked.
*
* <p>
* If EVAL_BODY_BUFFERED is returned, and the custom action element is not
* empty, setBodyContent() is invoked,
* doInitBody() is invoked, the body is evaluated, doAfterBody() is
* invoked, and then, after zero or more iterations, doEndTag() is invoked.
* If the custom action element is empty, only doStart() and doEndTag()
* are invoked.
*/
public interface BodyTag extends IterationTag {
/**
* Deprecated constant that has the same value as EVAL_BODY_BUFFERED
* and EVAL_BODY_AGAIN. This name has been marked as deprecated
* to encourage the use of the two different terms, which are much
* more descriptive.
*
* @deprecated As of Java JSP API 1.2, use BodyTag.EVAL_BODY_BUFFERED
* or IterationTag.EVAL_BODY_AGAIN.
*/
public final static int EVAL_BODY_TAG = 2;
/**
* Request the creation of new buffer, a BodyContent on which to
* evaluate the body of this tag.
*
* Returned from doStartTag when it implements BodyTag.
* This is an illegal return value for doStartTag when the class
* does not implement BodyTag.
*/
public final static int EVAL_BODY_BUFFERED = 2;
/**
* Set the bodyContent property.
* This method is invoked by the JSP page implementation object at
* most once per action invocation.
* This method will be invoked before doInitBody.
* This method will not be invoked for empty tags or for non-empty
* tags whose doStartTag() method returns SKIP_BODY or EVAL_BODY_INCLUDE.
*
* <p>
* When setBodyContent is invoked, the value of the implicit object out
* has already been changed in the pageContext object. The BodyContent
* object passed will have not data on it but may have been reused
* (and cleared) from some previous invocation.
*
* <p>
* The BodyContent object is available and with the appropriate content
* until after the invocation of the doEndTag method, at which case it
* may be reused.
*
* @param b the BodyContent
* @see #doInitBody
* @see #doAfterBody
*/
void setBodyContent(BodyContent b);
/**
* Prepare for evaluation of the body.
* This method is invoked by the JSP page implementation object
* after setBodyContent and before the first time
* the body is to be evaluated.
* This method will not be invoked for empty tags or for non-empty
* tags whose doStartTag() method returns SKIP_BODY or EVAL_BODY_INCLUDE.
*
* <p>
* The JSP container will resynchronize the values of any AT_BEGIN and
* NESTED variables (defined by the associated TagExtraInfo or TLD) after
* the invocation of doInitBody().
*
* @throws JspException if an error occurred while processing this tag
* @see #doAfterBody
*/
void doInitBody() throws JspException;
}
| 1,287 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/DynamicAttributes.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.JspException;
/**
* For a tag to declare that it accepts dynamic attributes, it must implement
* this interface. The entry for the tag in the Tag Library Descriptor must
* also be configured to indicate dynamic attributes are accepted.
* <br>
* For any attribute that is not declared in the Tag Library Descriptor for
* this tag, instead of getting an error at translation time, the
* <code>setDynamicAttribute()</code> method is called, with the name and
* value of the attribute. It is the responsibility of the tag to
* remember the names and values of the dynamic attributes.
*
* @since 2.0
*/
public interface DynamicAttributes {
/**
* Called when a tag declared to accept dynamic attributes is passed
* an attribute that is not declared in the Tag Library Descriptor.
*
* @param uri the namespace of the attribute, or null if in the default
* namespace.
* @param localName the name of the attribute being set.
* @param value the value of the attribute
* @throws JspException if the tag handler wishes to
* signal that it does not accept the given attribute. The
* container must not call doStartTag() or doTag() for this tag.
*/
public void setDynamicAttribute(
String uri, String localName, Object value )
throws JspException;
}
| 1,288 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/ValidationMessage.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* A validation message from either TagLibraryValidator or TagExtraInfo.
* <p>
* As of JSP 2.0, a JSP container must support a jsp:id attribute
* to provide higher quality validation errors.
* The container will track the JSP pages
* as passed to the container, and will assign to each element
* a unique "id", which is passed as the value of the jsp:id
* attribute. Each XML element in the XML view available will
* be extended with this attribute. The TagLibraryValidator
* can then use the attribute in one or more ValidationMessage
* objects. The container then, in turn, can use these
* values to provide more precise information on the location
* of an error.
*
* <p>
* The actual prefix of the <code>id</code> attribute may or may not be
* <code>jsp</code> but it will always map to the namespace
* <code>http://java.sun.com/JSP/Page</code>. A TagLibraryValidator
* implementation must rely on the uri, not the prefix, of the <code>id</code>
* attribute.
*/
public class ValidationMessage {
/**
* Create a ValidationMessage. The message String should be
* non-null. The value of id may be null, if the message
* is not specific to any XML element, or if no jsp:id
* attributes were passed on. If non-null, the value of
* id must be the value of a jsp:id attribute for the PageData
* passed into the validate() method.
*
* @param id Either null, or the value of a jsp:id attribute.
* @param message A localized validation message.
*/
public ValidationMessage(String id, String message) {
this.id = id;
this.message = message;
}
/**
* Get the jsp:id.
* Null means that there is no information available.
*
* @return The jsp:id information.
*/
public String getId() {
return id;
}
/**
* Get the localized validation message.
*
* @return A validation message
*/
public String getMessage(){
return message;
}
// Private data
private String id;
private String message;
}
| 1,289 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagLibraryValidator.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import java.util.Map;
/**
* Translation-time validator class for a JSP page.
* A validator operates on the XML view associated with the JSP page.
*
* <p>
* The TLD file associates a TagLibraryValidator class and some init
* arguments with a tag library.
*
* <p>
* The JSP container is reponsible for locating an appropriate
* instance of the appropriate subclass by
*
* <ul>
* <li> new a fresh instance, or reuse an available one
* <li> invoke the setInitParams(Map) method on the instance
* </ul>
*
* once initialized, the validate(String, String, PageData) method will
* be invoked, where the first two arguments are the prefix
* and uri for this tag library in the XML View. The prefix is intended
* to make it easier to produce an error message. However, it is not
* always accurate. In the case where a single URI is mapped to more
* than one prefix in the XML view, the prefix of the first URI is provided.
* Therefore, to provide high quality error messages in cases where the
* tag elements themselves are checked, the prefix parameter should be
* ignored and the actual prefix of the element should be used instead.
* TagLibraryValidators should always use the uri to identify elements
* as beloning to the tag library, not the prefix.
*
* <p>
* A TagLibraryValidator instance
* may create auxiliary objects internally to perform
* the validation (e.g. an XSchema validator) and may reuse it for all
* the pages in a given translation run.
*
* <p>
* The JSP container is not guaranteed to serialize invocations of
* validate() method, and TagLibraryValidators should perform any
* synchronization they may require.
*
* <p>
* As of JSP 2.0, a JSP container must provide a jsp:id attribute to
* provide higher quality validation errors.
* The container will track the JSP pages
* as passed to the container, and will assign to each element
* a unique "id", which is passed as the value of the jsp:id
* attribute. Each XML element in the XML view available will
* be extended with this attribute. The TagLibraryValidator
* can then use the attribute in one or more ValidationMessage
* objects. The container then, in turn, can use these
* values to provide more precise information on the location
* of an error.
*
* <p>
* The actual prefix of the <code>id</code> attribute may or may not be
* <code>jsp</code> but it will always map to the namespace
* <code>http://java.sun.com/JSP/Page</code>. A TagLibraryValidator
* implementation must rely on the uri, not the prefix, of the <code>id</code>
* attribute.
*/
abstract public class TagLibraryValidator {
/**
* Sole constructor. (For invocation by subclass constructors,
* typically implicit.)
*/
public TagLibraryValidator() {
}
/**
* Set the init data in the TLD for this validator.
* Parameter names are keys, and parameter values are the values.
*
* @param map A Map describing the init parameters
*/
public void setInitParameters(Map<String, Object> map) {
initParameters = map;
}
/**
* Get the init parameters data as an immutable Map.
* Parameter names are keys, and parameter values are the values.
*
* @return The init parameters as an immutable map.
*/
public Map<String, Object> getInitParameters() {
return initParameters;
}
/**
* Validate a JSP page.
* This will get invoked once per unique tag library URI in the
* XML view. This method will return null if the page is valid; otherwise
* the method should return an array of ValidationMessage objects.
* An array of length zero is also interpreted as no errors.
*
* @param prefix the first prefix with which the tag library is
* associated, in the XML view. Note that some tags may use
* a different prefix if the namespace is redefined.
* @param uri the tag library's unique identifier
* @param page the JspData page object
* @return A null object, or zero length array if no errors, an array
* of ValidationMessages otherwise.
*/
public ValidationMessage[] validate(String prefix, String uri,
PageData page)
{
return null;
}
/**
* Release any data kept by this instance for validation purposes.
*/
public void release() {
initParameters = null;
}
// Private data
private Map<String, Object> initParameters;
}
| 1,290 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/BodyTagSupport.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
/**
* A base class for defining tag handlers implementing BodyTag.
*
* <p>
* The BodyTagSupport class implements the BodyTag interface and adds
* additional convenience methods including getter methods for the
* bodyContent property and methods to get at the previous out JspWriter.
*
* <p>
* Many tag handlers will extend BodyTagSupport and only redefine a
* few methods.
*/
public class BodyTagSupport extends TagSupport implements BodyTag {
/**
* Default constructor, all subclasses are required to only define
* a public constructor with the same signature, and to call the
* superclass constructor.
*
* This constructor is called by the code generated by the JSP
* translator.
*/
public BodyTagSupport() {
super();
}
/**
* Default processing of the start tag returning EVAL_BODY_BUFFERED.
*
* @return EVAL_BODY_BUFFERED
* @throws JspException if an error occurred while processing this tag
* @see BodyTag#doStartTag
*/
public int doStartTag() throws JspException {
return EVAL_BODY_BUFFERED;
}
/**
* Default processing of the end tag returning EVAL_PAGE.
*
* @return EVAL_PAGE
* @throws JspException if an error occurred while processing this tag
* @see Tag#doEndTag
*/
public int doEndTag() throws JspException {
return super.doEndTag();
}
// Actions related to body evaluation
/**
* Prepare for evaluation of the body: stash the bodyContent away.
*
* @param b the BodyContent
* @see #doAfterBody
* @see #doInitBody()
* @see BodyTag#setBodyContent
*/
public void setBodyContent(BodyContent b) {
this.bodyContent = b;
}
/**
* Prepare for evaluation of the body just before the first body evaluation:
* no action.
*
* @throws JspException if an error occurred while processing this tag
* @see #setBodyContent
* @see #doAfterBody
* @see BodyTag#doInitBody
*/
public void doInitBody() throws JspException {
}
/**
* After the body evaluation: do not reevaluate and continue with the page.
* By default nothing is done with the bodyContent data (if any).
*
* @return SKIP_BODY
* @throws JspException if an error occurred while processing this tag
* @see #doInitBody
* @see BodyTag#doAfterBody
*/
public int doAfterBody() throws JspException {
return SKIP_BODY;
}
/**
* Release state.
*
* @see Tag#release
*/
public void release() {
bodyContent = null;
super.release();
}
/**
* Get current bodyContent.
*
* @return the body content.
*/
public BodyContent getBodyContent() {
return bodyContent;
}
/**
* Get surrounding out JspWriter.
*
* @return the enclosing JspWriter, from the bodyContent.
*/
public JspWriter getPreviousOut() {
return bodyContent.getEnclosingWriter();
}
// protected fields
/**
* The current BodyContent for this BodyTag.
*/
protected BodyContent bodyContent;
}
| 1,291 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/JspFragment.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import java.io.IOException;
import java.io.Writer;
import javax.servlet.jsp.*;
/**
* Encapsulates a portion of JSP code in an object that
* can be invoked as many times as needed. JSP Fragments are defined
* using JSP syntax as the body of a tag for an invocation to a SimpleTag
* handler, or as the body of a <jsp:attribute> standard action
* specifying the value of an attribute that is declared as a fragment,
* or to be of type JspFragment in the TLD.
* <p>
* The definition of the JSP fragment must only contain template
* text and JSP action elements. In other words, it must not contain
* scriptlets or scriptlet expressions. At translation time, the
* container generates an implementation of the JspFragment abstract class
* capable of executing the defined fragment.
* <p>
* A tag handler can invoke the fragment zero or more times, or
* pass it along to other tags, before returning. To communicate values
* to/from a JSP fragment, tag handlers store/retrieve values in
* the JspContext associated with the fragment.
* <p>
* Note that tag library developers and page authors should not generate
* JspFragment implementations manually.
* <p>
* <i>Implementation Note</i>: It is not necessary to generate a
* separate class for each fragment. One possible implementation is
* to generate a single helper class for each page that implements
* JspFragment. Upon construction, a discriminator can be passed to
* select which fragment that instance will execute.
*
* @since 2.0
*/
public abstract class JspFragment {
/**
* Executes the fragment and directs all output to the given Writer,
* or the JspWriter returned by the getOut() method of the JspContext
* associated with the fragment if out is null.
*
* @param out The Writer to output the fragment to, or null if
* output should be sent to JspContext.getOut().
* @throws javax.servlet.jsp.JspException Thrown if an error occured
* while invoking this fragment.
* @throws javax.servlet.jsp.SkipPageException Thrown if the page
* that (either directly or indirectly) invoked the tag handler that
* invoked this fragment is to cease evaluation. The container
* must throw this exception if a Classic Tag Handler returned
* Tag.SKIP_PAGE or if a Simple Tag Handler threw SkipPageException.
* @throws java.io.IOException If there was an error writing to the
* stream.
*/
public abstract void invoke( Writer out )
throws JspException, IOException;
/**
* Returns the JspContext that is bound to this JspFragment.
*
* @return The JspContext used by this fragment at invocation time.
*/
public abstract JspContext getJspContext();
}
| 1,292 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagData.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import java.util.Hashtable;
/**
* The (translation-time only) attribute/value information for a tag instance.
*
* <p>
* TagData is only used as an argument to the isValid, validate, and
* getVariableInfo methods of TagExtraInfo, which are invoked at
* translation time.
*/
public class TagData implements Cloneable {
/**
* Distinguished value for an attribute to indicate its value
* is a request-time expression (which is not yet available because
* TagData instances are used at translation-time).
*/
public static final Object REQUEST_TIME_VALUE = new Object();
/**
* Constructor for TagData.
*
* <p>
* A typical constructor may be
* <pre>
* static final Object[][] att = {{"connection", "conn0"}, {"id", "query0"}};
* static final TagData td = new TagData(att);
* </pre>
*
* All values must be Strings except for those holding the
* distinguished object REQUEST_TIME_VALUE.
* @param atts the static attribute and values. May be null.
*/
public TagData(Object[] atts[]) {
if (atts == null) {
attributes = new Hashtable<String, Object>();
} else {
attributes = new Hashtable<String, Object>(atts.length);
}
if (atts != null) {
for (int i = 0; i < atts.length; i++) {
attributes.put((String) atts[i][0], atts[i][1]);
}
}
}
/**
* Constructor for a TagData.
*
* If you already have the attributes in a hashtable, use this
* constructor.
*
* @param attrs A hashtable to get the values from.
*/
public TagData(Hashtable<String, Object> attrs) {
this.attributes = attrs;
}
/**
* The value of the tag's id attribute.
*
* @return the value of the tag's id attribute, or null if no such
* attribute was specified.
*/
public String getId() {
return getAttributeString(TagAttributeInfo.ID);
}
/**
* The value of the attribute.
* If a static value is specified for an attribute that accepts a
* request-time attribute expression then that static value is returned,
* even if the value is provided in the body of a <jsp:attribute> action.
* The distinguished object REQUEST_TIME_VALUE is only returned if
* the value is specified as a request-time attribute expression
* or via the <jsp:attribute> action with a body that contains
* dynamic content (scriptlets, scripting expressions, EL expressions,
* standard actions, or custom actions). Returns null if the attribute
* is not set.
*
* @param attName the name of the attribute
* @return the attribute's value
*/
public Object getAttribute(String attName) {
return attributes.get(attName);
}
/**
* Set the value of an attribute.
*
* @param attName the name of the attribute
* @param value the value.
*/
public void setAttribute(String attName,
Object value) {
attributes.put(attName, value);
}
/**
* Get the value for a given attribute.
*
* @param attName the name of the attribute
* @return the attribute value string
* @throws ClassCastException if attribute value is not a String
*/
public String getAttributeString(String attName) {
Object o = attributes.get(attName);
if (o == null) {
return null;
} else {
return (String) o;
}
}
/**
* Enumerates the attributes.
*
*@return An enumeration of the attributes in a TagData
*/
public java.util.Enumeration<String> getAttributes() {
return attributes.keys();
};
// private data
private Hashtable<String, Object> attributes; // the tagname/value map
}
| 1,293 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagSupport.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
/**
* A base class for defining new tag handlers implementing Tag.
*
* <p> The TagSupport class is a utility class intended to be used as
* the base class for new tag handlers. The TagSupport class
* implements the Tag and IterationTag interfaces and adds additional
* convenience methods including getter methods for the properties in
* Tag. TagSupport has one static method that is included to
* facilitate coordination among cooperating tags.
*
* <p> Many tag handlers will extend TagSupport and only redefine a
* few methods.
*/
public class TagSupport implements IterationTag, Serializable {
/**
* Find the instance of a given class type that is closest to a given
* instance.
* This method uses the getParent method from the Tag
* interface.
* This method is used for coordination among cooperating tags.
*
* <p>
* The current version of the specification only provides one formal
* way of indicating the observable type of a tag handler: its
* tag handler implementation class, described in the tag-class
* subelement of the tag element. This is extended in an
* informal manner by allowing the tag library author to
* indicate in the description subelement an observable type.
* The type should be a subtype of the tag handler implementation
* class or void.
* This addititional constraint can be exploited by a
* specialized container that knows about that specific tag library,
* as in the case of the JSP standard tag library.
*
* <p>
* When a tag library author provides information on the
* observable type of a tag handler, client programmatic code
* should adhere to that constraint. Specifically, the Class
* passed to findAncestorWithClass should be a subtype of the
* observable type.
*
*
* @param from The instance from where to start looking.
* @param klass The subclass of Tag or interface to be matched
* @return the nearest ancestor that implements the interface
* or is an instance of the class specified
*/
public static final Tag findAncestorWithClass(Tag from, Class klass) {
boolean isInterface = false;
if (from == null ||
klass == null ||
(!Tag.class.isAssignableFrom(klass) &&
!(isInterface = klass.isInterface()))) {
return null;
}
for (;;) {
Tag tag = from.getParent();
if (tag == null) {
return null;
}
if ((isInterface && klass.isInstance(tag)) ||
klass.isAssignableFrom(tag.getClass()))
return tag;
else
from = tag;
}
}
/**
* Default constructor, all subclasses are required to define only
* a public constructor with the same signature, and to call the
* superclass constructor.
*
* This constructor is called by the code generated by the JSP
* translator.
*/
public TagSupport() { }
/**
* Default processing of the start tag, returning SKIP_BODY.
*
* @return SKIP_BODY
* @throws JspException if an error occurs while processing this tag
*
* @see Tag#doStartTag()
*/
public int doStartTag() throws JspException {
return SKIP_BODY;
}
/**
* Default processing of the end tag returning EVAL_PAGE.
*
* @return EVAL_PAGE
* @throws JspException if an error occurs while processing this tag
*
* @see Tag#doEndTag()
*/
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
/**
* Default processing for a body.
*
* @return SKIP_BODY
* @throws JspException if an error occurs while processing this tag
*
* @see IterationTag#doAfterBody()
*/
public int doAfterBody() throws JspException {
return SKIP_BODY;
}
// Actions related to body evaluation
/**
* Release state.
*
* @see Tag#release()
*/
public void release() {
parent = null;
id = null;
if( values != null ) {
values.clear();
}
values = null;
}
/**
* Set the nesting tag of this tag.
*
* @param t The parent Tag.
* @see Tag#setParent(Tag)
*/
public void setParent(Tag t) {
parent = t;
}
/**
* The Tag instance most closely enclosing this tag instance.
* @see Tag#getParent()
*
* @return the parent tag instance or null
*/
public Tag getParent() {
return parent;
}
/**
* Set the id attribute for this tag.
*
* @param id The String for the id.
*/
public void setId(String id) {
this.id = id;
}
/**
* The value of the id attribute of this tag; or null.
*
* @return the value of the id attribute, or null
*/
public String getId() {
return id;
}
/**
* Set the page context.
*
* @param pageContext The PageContext.
* @see Tag#setPageContext
*/
public void setPageContext(PageContext pageContext) {
this.pageContext = pageContext;
}
/**
* Associate a value with a String key.
*
* @param k The key String.
* @param o The value to associate.
*/
public void setValue(String k, Object o) {
if (values == null) {
values = new Hashtable<String, Object>();
}
values.put(k, o);
}
/**
* Get a the value associated with a key.
*
* @param k The string key.
* @return The value associated with the key, or null.
*/
public Object getValue(String k) {
if (values == null) {
return null;
} else {
return values.get(k);
}
}
/**
* Remove a value associated with a key.
*
* @param k The string key.
*/
public void removeValue(String k) {
if (values != null) {
values.remove(k);
}
}
/**
* Enumerate the keys for the values kept by this tag handler.
*
* @return An enumeration of all the keys for the values set,
* or null or an empty Enumeration if no values have been set.
*/
public Enumeration<String> getValues() {
if (values == null) {
return null;
}
return values.keys();
}
// private fields
private Tag parent;
private Hashtable<String, Object> values;
/**
* The value of the id attribute of this tag; or null.
*/
protected String id;
// protected fields
/**
* The PageContext.
*/
protected PageContext pageContext;
}
| 1,294 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/IterationTag.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
import javax.servlet.jsp.*;
/**
* The IterationTag interface extends Tag by defining one additional
* method that controls the reevaluation of its body.
*
* <p> A tag handler that implements IterationTag is treated as one that
* implements Tag regarding the doStartTag() and doEndTag() methods.
* IterationTag provides a new method: <code>doAfterBody()</code>.
*
* <p> The doAfterBody() method is invoked after every body evaluation
* to control whether the body will be reevaluated or not. If doAfterBody()
* returns IterationTag.EVAL_BODY_AGAIN, then the body will be reevaluated.
* If doAfterBody() returns Tag.SKIP_BODY, then the body will be skipped
* and doEndTag() will be evaluated instead.
*
* <p><B>Properties</B>
* There are no new properties in addition to those in Tag.
*
* <p><B>Methods</B>
* There is one new methods: doAfterBody().
*
* <p><B>Lifecycle</B>
*
* <p> Lifecycle details are described by the transition diagram
* below. Exceptions that are thrown during the computation of
* doStartTag(), BODY and doAfterBody() interrupt the execution
* sequence and are propagated up the stack, unless the tag handler
* implements the TryCatchFinally interface; see that interface for
* details.
*
* <p>
* <IMG src="doc-files/IterationTagProtocol.gif"
* alt="Lifecycle Details Transition Diagram for IterationTag"/>
*
* <p><B>Empty and Non-Empty Action</B>
* <p> If the TagLibraryDescriptor file indicates that the action must
* always have an empty element body, by a <body-content> entry of
* "empty", then the doStartTag() method must return SKIP_BODY.
*
* <p>Note that which methods are invoked after the doStartTag() depends on
* both the return value and on if the custom action element is empty
* or not in the JSP page, not on how it's declared in the TLD.
*
* <p>
* If SKIP_BODY is returned the body is not evaluated, and then doEndTag()
* is invoked.
*
* <p>
* If EVAL_BODY_INCLUDE is returned, and the custom action element is not
* empty, the body is evaluated and "passed through" to the current out,
* then doAfterBody() is invoked and, after zero or more iterations,
* doEndTag() is invoked.
*/
public interface IterationTag extends Tag {
/**
* Request the reevaluation of some body.
* Returned from doAfterBody.
*
* For compatibility with JSP 1.1, the value is carefully selected
* to be the same as the, now deprecated, BodyTag.EVAL_BODY_TAG,
*
*/
public final static int EVAL_BODY_AGAIN = 2;
/**
* Process body (re)evaluation. This method is invoked by the
* JSP Page implementation object after every evaluation of
* the body into the BodyEvaluation object. The method is
* not invoked if there is no body evaluation.
*
* <p>
* If doAfterBody returns EVAL_BODY_AGAIN, a new evaluation of the
* body will happen (followed by another invocation of doAfterBody).
* If doAfterBody returns SKIP_BODY, no more body evaluations will occur,
* and the doEndTag method will be invoked.
*
* <p>
* If this tag handler implements BodyTag and doAfterBody returns
* SKIP_BODY, the value of out will be restored using the popBody
* method in pageContext prior to invoking doEndTag.
*
* <p>
* The method re-invocations may be lead to different actions because
* there might have been some changes to shared state, or because
* of external computation.
*
* <p>
* The JSP container will resynchronize the values of any AT_BEGIN and
* NESTED variables (defined by the associated TagExtraInfo or TLD) after
* the invocation of doAfterBody().
*
* @return whether additional evaluations of the body are desired
* @throws JspException if an error occurred while processing this tag
*/
int doAfterBody() throws JspException;
}
| 1,295 |
0 | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp | Create_ds/geronimo-specs/geronimo-jsp_2.2_spec/src/main/java/javax/servlet/jsp/tagext/TagInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.tagext;
/**
* Tag information for a tag in a Tag Library;
* This class is instantiated from the Tag Library Descriptor file (TLD)
* and is available only at translation time.
*
*
*/
public class TagInfo {
/**
* Static constant for getBodyContent() when it is JSP.
*/
public static final String BODY_CONTENT_JSP = "JSP";
/**
* Static constant for getBodyContent() when it is Tag dependent.
*/
public static final String BODY_CONTENT_TAG_DEPENDENT = "tagdependent";
/**
* Static constant for getBodyContent() when it is empty.
*/
public static final String BODY_CONTENT_EMPTY = "empty";
/**
* Static constant for getBodyContent() when it is scriptless.
*
* @since 2.0
*/
public static final String BODY_CONTENT_SCRIPTLESS = "scriptless";
/**
* Constructor for TagInfo from data in the JSP 1.1 format for TLD.
* This class is to be instantiated only from the TagLibrary code
* under request from some JSP code that is parsing a
* TLD (Tag Library Descriptor).
*
* Note that, since TagLibibraryInfo reflects both TLD information
* and taglib directive information, a TagInfo instance is
* dependent on a taglib directive. This is probably a
* design error, which may be fixed in the future.
*
* @param tagName The name of this tag
* @param tagClassName The name of the tag handler class
* @param bodycontent Information on the body content of these tags
* @param infoString The (optional) string information for this tag
* @param taglib The instance of the tag library that contains us.
* @param tagExtraInfo The instance providing extra Tag info. May be null
* @param attributeInfo An array of AttributeInfo data from descriptor.
* May be null;
*
*/
public TagInfo(String tagName,
String tagClassName,
String bodycontent,
String infoString,
TagLibraryInfo taglib,
TagExtraInfo tagExtraInfo,
TagAttributeInfo[] attributeInfo) {
this.tagName = tagName;
this.tagClassName = tagClassName;
this.bodyContent = bodycontent;
this.infoString = infoString;
this.tagLibrary = taglib;
this.tagExtraInfo = tagExtraInfo;
this.attributeInfo = attributeInfo;
if (tagExtraInfo != null)
tagExtraInfo.setTagInfo(this);
}
/**
* Constructor for TagInfo from data in the JSP 1.2 format for TLD.
* This class is to be instantiated only from the TagLibrary code
* under request from some JSP code that is parsing a
* TLD (Tag Library Descriptor).
*
* Note that, since TagLibibraryInfo reflects both TLD information
* and taglib directive information, a TagInfo instance is
* dependent on a taglib directive. This is probably a
* design error, which may be fixed in the future.
*
* @param tagName The name of this tag
* @param tagClassName The name of the tag handler class
* @param bodycontent Information on the body content of these tags
* @param infoString The (optional) string information for this tag
* @param taglib The instance of the tag library that contains us.
* @param tagExtraInfo The instance providing extra Tag info. May be null
* @param attributeInfo An array of AttributeInfo data from descriptor.
* May be null;
* @param displayName A short name to be displayed by tools
* @param smallIcon Path to a small icon to be displayed by tools
* @param largeIcon Path to a large icon to be displayed by tools
* @param tvi An array of a TagVariableInfo (or null)
*/
public TagInfo(String tagName,
String tagClassName,
String bodycontent,
String infoString,
TagLibraryInfo taglib,
TagExtraInfo tagExtraInfo,
TagAttributeInfo[] attributeInfo,
String displayName,
String smallIcon,
String largeIcon,
TagVariableInfo[] tvi) {
this.tagName = tagName;
this.tagClassName = tagClassName;
this.bodyContent = bodycontent;
this.infoString = infoString;
this.tagLibrary = taglib;
this.tagExtraInfo = tagExtraInfo;
this.attributeInfo = attributeInfo;
this.displayName = displayName;
this.smallIcon = smallIcon;
this.largeIcon = largeIcon;
this.tagVariableInfo = tvi;
if (tagExtraInfo != null)
tagExtraInfo.setTagInfo(this);
}
/**
* Constructor for TagInfo from data in the JSP 2.0 format for TLD.
* This class is to be instantiated only from the TagLibrary code
* under request from some JSP code that is parsing a
* TLD (Tag Library Descriptor).
*
* Note that, since TagLibibraryInfo reflects both TLD information
* and taglib directive information, a TagInfo instance is
* dependent on a taglib directive. This is probably a
* design error, which may be fixed in the future.
*
* @param tagName The name of this tag
* @param tagClassName The name of the tag handler class
* @param bodycontent Information on the body content of these tags
* @param infoString The (optional) string information for this tag
* @param taglib The instance of the tag library that contains us.
* @param tagExtraInfo The instance providing extra Tag info. May be null
* @param attributeInfo An array of AttributeInfo data from descriptor.
* May be null;
* @param displayName A short name to be displayed by tools
* @param smallIcon Path to a small icon to be displayed by tools
* @param largeIcon Path to a large icon to be displayed by tools
* @param tvi An array of a TagVariableInfo (or null)
* @param dynamicAttributes True if supports dynamic attributes
*
* @since 2.0
*/
public TagInfo(String tagName,
String tagClassName,
String bodycontent,
String infoString,
TagLibraryInfo taglib,
TagExtraInfo tagExtraInfo,
TagAttributeInfo[] attributeInfo,
String displayName,
String smallIcon,
String largeIcon,
TagVariableInfo[] tvi,
boolean dynamicAttributes) {
this.tagName = tagName;
this.tagClassName = tagClassName;
this.bodyContent = bodycontent;
this.infoString = infoString;
this.tagLibrary = taglib;
this.tagExtraInfo = tagExtraInfo;
this.attributeInfo = attributeInfo;
this.displayName = displayName;
this.smallIcon = smallIcon;
this.largeIcon = largeIcon;
this.tagVariableInfo = tvi;
this.dynamicAttributes = dynamicAttributes;
if (tagExtraInfo != null)
tagExtraInfo.setTagInfo(this);
}
/**
* The name of the Tag.
*
* @return The (short) name of the tag.
*/
public String getTagName() {
return tagName;
}
/**
* Attribute information (in the TLD) on this tag.
* The return is an array describing the attributes of this tag, as
* indicated in the TLD.
*
* @return The array of TagAttributeInfo for this tag, or a
* zero-length array if the tag has no attributes.
*/
public TagAttributeInfo[] getAttributes() {
return attributeInfo;
}
/**
* Information on the scripting objects created by this tag at runtime.
* This is a convenience method on the associated TagExtraInfo class.
*
* @param data TagData describing this action.
* @return if a TagExtraInfo object is associated with this TagInfo, the
* result of getTagExtraInfo().getVariableInfo( data ), otherwise
* null.
*/
public VariableInfo[] getVariableInfo(TagData data) {
VariableInfo[] result = null;
TagExtraInfo tei = getTagExtraInfo();
if (tei != null) {
result = tei.getVariableInfo( data );
}
return result;
}
/**
* Translation-time validation of the attributes.
* This is a convenience method on the associated TagExtraInfo class.
*
* @param data The translation-time TagData instance.
* @return Whether the data is valid.
*/
public boolean isValid(TagData data) {
TagExtraInfo tei = getTagExtraInfo();
if (tei == null) {
return true;
}
return tei.isValid(data);
}
/**
* Translation-time validation of the attributes.
* This is a convenience method on the associated TagExtraInfo class.
*
* @param data The translation-time TagData instance.
* @return A null object, or zero length array if no errors, an
* array of ValidationMessages otherwise.
* @since 2.0
*/
public ValidationMessage[] validate( TagData data ) {
TagExtraInfo tei = getTagExtraInfo();
if( tei == null ) {
return null;
}
return tei.validate( data );
}
/**
* Set the instance for extra tag information.
*
* @param tei the TagExtraInfo instance
*/
public void setTagExtraInfo(TagExtraInfo tei) {
tagExtraInfo = tei;
}
/**
* The instance (if any) for extra tag information.
*
* @return The TagExtraInfo instance, if any.
*/
public TagExtraInfo getTagExtraInfo() {
return tagExtraInfo;
}
/**
* Name of the class that provides the handler for this tag.
*
* @return The name of the tag handler class.
*/
public String getTagClassName() {
return tagClassName;
}
/**
* The bodycontent information for this tag.
* If the bodycontent is not defined for this
* tag, the default of JSP will be returned.
*
* @return the body content string.
*/
public String getBodyContent() {
return bodyContent;
}
/**
* The information string for the tag.
*
* @return the info string, or null if
* not defined
*/
public String getInfoString() {
return infoString;
}
/**
* Set the TagLibraryInfo property.
*
* Note that a TagLibraryInfo element is dependent
* not just on the TLD information but also on the
* specific taglib instance used. This means that
* a fair amount of work needs to be done to construct
* and initialize TagLib objects.
*
* If used carefully, this setter can be used to avoid having to
* create new TagInfo elements for each taglib directive.
*
* @param tl the TagLibraryInfo to assign
*/
public void setTagLibrary(TagLibraryInfo tl) {
tagLibrary = tl;
}
/**
* The instance of TabLibraryInfo we belong to.
*
* @return the tag library instance we belong to
*/
public TagLibraryInfo getTagLibrary() {
return tagLibrary;
}
// ============== JSP 2.0 TLD Information ========
/**
* Get the displayName.
*
* @return A short name to be displayed by tools,
* or null if not defined
*/
public String getDisplayName() {
return displayName;
}
/**
* Get the path to the small icon.
*
* @return Path to a small icon to be displayed by tools,
* or null if not defined
*/
public String getSmallIcon() {
return smallIcon;
}
/**
* Get the path to the large icon.
*
* @return Path to a large icon to be displayed by tools,
* or null if not defined
*/
public String getLargeIcon() {
return largeIcon;
}
/**
* Get TagVariableInfo objects associated with this TagInfo.
*
* @return Array of TagVariableInfo objects corresponding to
* variables declared by this tag, or a zero length
* array if no variables have been declared
*/
public TagVariableInfo[] getTagVariableInfos() {
return tagVariableInfo;
}
// ============== JSP 2.0 TLD Information ========
/**
* Get dynamicAttributes associated with this TagInfo.
*
* @return True if tag handler supports dynamic attributes
* @since 2.0
*/
public boolean hasDynamicAttributes() {
return dynamicAttributes;
}
/*
* private fields for 1.1 info
*/
private String tagName; // the name of the tag
private String tagClassName;
private String bodyContent;
private String infoString;
private TagLibraryInfo tagLibrary;
private TagExtraInfo tagExtraInfo; // instance of TagExtraInfo
private TagAttributeInfo[] attributeInfo;
/*
* private fields for 1.2 info
*/
private String displayName;
private String smallIcon;
private String largeIcon;
private TagVariableInfo[] tagVariableInfo;
/*
* Additional private fields for 2.0 info
*/
private boolean dynamicAttributes;
}
| 1,296 |
0 | Create_ds/geronimo-specs/geronimo-javaee-deployment_1.1MR3_spec/src/test/java/javax/enterprise/deploy | Create_ds/geronimo-specs/geronimo-javaee-deployment_1.1MR3_spec/src/test/java/javax/enterprise/deploy/shared/StateTypeTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.enterprise.deploy.shared;
import junit.framework.TestCase;
/**
* @version $Rev$ $Date$
*/
public class StateTypeTest extends TestCase {
public void testValues() {
assertEquals(0, StateType.RUNNING.getValue());
assertEquals(1, StateType.COMPLETED.getValue());
assertEquals(2, StateType.FAILED.getValue());
assertEquals(3, StateType.RELEASED.getValue());
}
public void testToString() {
assertEquals("running", StateType.RUNNING.toString());
assertEquals("completed", StateType.COMPLETED.toString());
assertEquals("failed", StateType.FAILED.toString());
assertEquals("released", StateType.RELEASED.toString());
// only possible due to package local access
assertEquals("5", new ActionType(5).toString());
}
public void testValueToSmall() {
try {
StateType.getStateType(-1);
fail("Expected AIOOBE");
} catch (ArrayIndexOutOfBoundsException aioobe) {
}
}
public void testValueToLarge() {
try {
StateType.getStateType(5);
fail("Expected AIOOBE");
} catch (ArrayIndexOutOfBoundsException aioobe) {
}
}
}
| 1,297 |
0 | Create_ds/geronimo-specs/geronimo-javaee-deployment_1.1MR3_spec/src/test/java/javax/enterprise/deploy | Create_ds/geronimo-specs/geronimo-javaee-deployment_1.1MR3_spec/src/test/java/javax/enterprise/deploy/shared/CommandTypeTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.enterprise.deploy.shared;
import junit.framework.TestCase;
/**
* @version $Rev$ $Date$
*/
public class CommandTypeTest extends TestCase {
public void testValues() {
assertEquals(0, CommandType.DISTRIBUTE.getValue());
assertEquals(1, CommandType.START.getValue());
assertEquals(2, CommandType.STOP.getValue());
assertEquals(3, CommandType.UNDEPLOY.getValue());
assertEquals(4, CommandType.REDEPLOY.getValue());
}
public void testToString() {
assertEquals("distribute", CommandType.DISTRIBUTE.toString());
assertEquals("start", CommandType.START.toString());
assertEquals("stop", CommandType.STOP.toString());
assertEquals("undeploy", CommandType.UNDEPLOY.toString());
assertEquals("redeploy", CommandType.REDEPLOY.toString());
// only possible due to package local access
assertEquals("10", new ActionType(10).toString());
assertEquals("-1", new ActionType(-1).toString());
}
public void testValueToSmall() {
try {
CommandType.getCommandType(-1);
fail("Expected AIOOBE");
} catch (ArrayIndexOutOfBoundsException aioobe) {
}
}
public void testValueToLarge() {
try {
CommandType.getCommandType(10);
fail("Expected AIOOBE");
} catch (ArrayIndexOutOfBoundsException aioobe) {
}
}
}
| 1,298 |
0 | Create_ds/geronimo-specs/geronimo-javaee-deployment_1.1MR3_spec/src/test/java/javax/enterprise/deploy | Create_ds/geronimo-specs/geronimo-javaee-deployment_1.1MR3_spec/src/test/java/javax/enterprise/deploy/shared/ModuleTypeTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//
// This source code implements specifications defined by the Java
// Community Process. In order to remain compliant with the specification
// DO NOT add / change / or delete method signatures!
//
package javax.enterprise.deploy.shared;
import junit.framework.TestCase;
/**
* @version $Rev$ $Date$
*/
public class ModuleTypeTest extends TestCase {
public void testValues() {
assertEquals(0, ModuleType.EAR.getValue());
assertEquals(1, ModuleType.EJB.getValue());
assertEquals(2, ModuleType.CAR.getValue());
assertEquals(3, ModuleType.RAR.getValue());
assertEquals(4, ModuleType.WAR.getValue());
}
public void testToString() {
assertEquals("ear", ModuleType.EAR.toString());
assertEquals("ejb", ModuleType.EJB.toString());
assertEquals("car", ModuleType.CAR.toString());
assertEquals("rar", ModuleType.RAR.toString());
assertEquals("war", ModuleType.WAR.toString());
// only possible due to package local access
assertEquals("5", new ModuleType(5).toString());
}
public void testModuleExtension() {
assertEquals(".ear", ModuleType.EAR.getModuleExtension());
assertEquals(".jar", ModuleType.EJB.getModuleExtension());
assertEquals(".jar", ModuleType.CAR.getModuleExtension());
assertEquals(".rar", ModuleType.RAR.getModuleExtension());
assertEquals(".war", ModuleType.WAR.getModuleExtension());
}
public void testValueToSmall() {
try {
ModuleType.getModuleType(-1);
fail("Expected AIOOBE");
} catch (ArrayIndexOutOfBoundsException aioobe) {
}
}
public void testValueToLarge() {
try {
ModuleType.getModuleType(5);
fail("Expected AIOOBE");
} catch (ArrayIndexOutOfBoundsException aioobe) {
}
}
}
| 1,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.