From 70c28a0bc5b35e9851a4ee3b757729df74fe3eb2 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Wed, 16 Nov 2011 18:23:56 +0000 Subject: [PATCH] Add Apache license header where missing in src/main --- .../cache/annotation/CachingConfigurer.java | 16 + .../annotation/AutoProxyRegistrar.java | 16 + .../jmx/support/MetricType.java | 24 +- .../common/TemplateAwareExpressionParser.java | 280 +++++++++++++++++- .../PostgresCallMetaDataProvider.java | 18 +- .../PostgresTableMetaDataProvider.java | 18 +- .../NamedParameterBatchUpdateUtils.java | 16 + .../SybaseAnywhereMaxValueIncrementer.java | 17 +- .../SybaseMaxValueIncrementer.java | 16 + .../HandlerExceptionResolverComposite.java | 18 +- .../web/bind/annotation/PathVariable.java | 21 +- 11 files changed, 448 insertions(+), 12 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/cache/annotation/CachingConfigurer.java b/org.springframework.context/src/main/java/org/springframework/cache/annotation/CachingConfigurer.java index 29ebd573c3..b3dd6224c5 100644 --- a/org.springframework.context/src/main/java/org/springframework/cache/annotation/CachingConfigurer.java +++ b/org.springframework.context/src/main/java/org/springframework/cache/annotation/CachingConfigurer.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2011 the original author or authors. + * + * Licensed 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.springframework.cache.annotation; import org.springframework.cache.CacheManager; diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java index 4f39f7af71..2e063a85fc 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java @@ -1,3 +1,19 @@ + /* + * Copyright 2002-2011 the original author or authors. + * + * Licensed 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.springframework.context.annotation; import java.util.Map; diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/support/MetricType.java b/org.springframework.context/src/main/java/org/springframework/jmx/support/MetricType.java index 28e47a70be..98bba2754f 100644 --- a/org.springframework.context/src/main/java/org/springframework/jmx/support/MetricType.java +++ b/org.springframework.context/src/main/java/org/springframework/jmx/support/MetricType.java @@ -1,20 +1,36 @@ -package org.springframework.jmx.support; +/* + * Copyright 2002-2011 the original author or authors. + * + * Licensed 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.springframework.jmx.support; /** - * Represents how the measurement values of a ManagedMetric will change over time + * Represents how the measurement values of a {@code ManagedMetric} will change over time. * @author Jennifer Hickey * @since 3.0 - * */ public enum MetricType { + /** * The measurement values may go up or down over time */ GAUGE, - + /** * The measurement values will always increase */ COUNTER + } diff --git a/org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java b/org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java index 7385c81716..4571595eba 100644 --- a/org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java +++ b/org.springframework.expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java @@ -1 +1,279 @@ -/* 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.springframework.expression.common; import java.util.LinkedList; import java.util.List; import java.util.Stack; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.ParseException; import org.springframework.expression.ParserContext; /** * An expression parser that understands templates. It can be subclassed * by expression parsers that do not offer first class support for templating. * * @author Keith Donald * @author Juergen Hoeller * @author Andy Clement * @since 3.0 */ public abstract class TemplateAwareExpressionParser implements ExpressionParser { /** * Default ParserContext instance for non-template expressions. */ private static final ParserContext NON_TEMPLATE_PARSER_CONTEXT = new ParserContext() { public String getExpressionPrefix() { return null; } public String getExpressionSuffix() { return null; } public boolean isTemplate() { return false; } }; public Expression parseExpression(String expressionString) throws ParseException { return parseExpression(expressionString, NON_TEMPLATE_PARSER_CONTEXT); } public Expression parseExpression(String expressionString, ParserContext context) throws ParseException { if (context == null) { context = NON_TEMPLATE_PARSER_CONTEXT; } if (context.isTemplate()) { return parseTemplate(expressionString, context); } else { return doParseExpression(expressionString, context); } } private Expression parseTemplate(String expressionString, ParserContext context) throws ParseException { if (expressionString.length() == 0) { return new LiteralExpression(""); } Expression[] expressions = parseExpressions(expressionString, context); if (expressions.length == 1) { return expressions[0]; } else { return new CompositeStringExpression(expressionString, expressions); } } /** * Helper that parses given expression string using the configured parser. The expression string can contain any * number of expressions all contained in "${...}" markers. For instance: "foo${expr0}bar${expr1}". The static * pieces of text will also be returned as Expressions that just return that static piece of text. As a result, * evaluating all returned expressions and concatenating the results produces the complete evaluated string. * Unwrapping is only done of the outermost delimiters found, so the string 'hello ${foo${abc}}' would break into * the pieces 'hello ' and 'foo${abc}'. This means that expression languages that used ${..} as part of their * functionality are supported without any problem. * The parsing is aware of the structure of an embedded expression. It assumes that parentheses '(', * square brackets '[' and curly brackets '}' must be in pairs within the expression unless they are within a * string literal and a string literal starts and terminates with a single quote '. * * @param expressionString the expression string * @return the parsed expressions * @throws ParseException when the expressions cannot be parsed */ private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParseException { List expressions = new LinkedList(); String prefix = context.getExpressionPrefix(); String suffix = context.getExpressionSuffix(); int startIdx = 0; while (startIdx < expressionString.length()) { int prefixIndex = expressionString.indexOf(prefix,startIdx); if (prefixIndex >= startIdx) { // an inner expression was found - this is a composite if (prefixIndex > startIdx) { expressions.add(createLiteralExpression(context,expressionString.substring(startIdx, prefixIndex))); } int afterPrefixIndex = prefixIndex + prefix.length(); int suffixIndex = skipToCorrectEndSuffix(prefix,suffix,expressionString,afterPrefixIndex); if (suffixIndex == -1) { throw new ParseException(expressionString, prefixIndex, "No ending suffix '" + suffix + "' for expression starting at character " + prefixIndex + ": " + expressionString.substring(prefixIndex)); } if (suffixIndex == afterPrefixIndex) { throw new ParseException(expressionString, prefixIndex, "No expression defined within delimiter '" + prefix + suffix + "' at character " + prefixIndex); } else { String expr = expressionString.substring(prefixIndex + prefix.length(), suffixIndex); expr = expr.trim(); if (expr.length()==0) { throw new ParseException(expressionString, prefixIndex, "No expression defined within delimiter '" + prefix + suffix + "' at character " + prefixIndex); } expressions.add(doParseExpression(expr, context)); startIdx = suffixIndex + suffix.length(); } } else { // no more ${expressions} found in string, add rest as static text expressions.add(createLiteralExpression(context,expressionString.substring(startIdx))); startIdx = expressionString.length(); } } return expressions.toArray(new Expression[expressions.size()]); } private Expression createLiteralExpression(ParserContext context, String text) { return new LiteralExpression(text); } /** * Return true if the specified suffix can be found at the supplied position in the supplied expression string. * @param expressionString the expression string which may contain the suffix * @param pos the start position at which to check for the suffix * @param suffix the suffix string * @return */ private boolean isSuffixHere(String expressionString,int pos,String suffix) { int suffixPosition = 0; for (int i=0;i stack = new Stack(); while (pos expressions = new LinkedList(); + String prefix = context.getExpressionPrefix(); + String suffix = context.getExpressionSuffix(); + int startIdx = 0; + while (startIdx < expressionString.length()) { + int prefixIndex = expressionString.indexOf(prefix,startIdx); + if (prefixIndex >= startIdx) { + // an inner expression was found - this is a composite + if (prefixIndex > startIdx) { + expressions.add(createLiteralExpression(context,expressionString.substring(startIdx, prefixIndex))); + } + int afterPrefixIndex = prefixIndex + prefix.length(); + int suffixIndex = skipToCorrectEndSuffix(prefix,suffix,expressionString,afterPrefixIndex); + if (suffixIndex == -1) { + throw new ParseException(expressionString, prefixIndex, "No ending suffix '" + suffix + + "' for expression starting at character " + prefixIndex + ": " + + expressionString.substring(prefixIndex)); + } + if (suffixIndex == afterPrefixIndex) { + throw new ParseException(expressionString, prefixIndex, "No expression defined within delimiter '" + + prefix + suffix + "' at character " + prefixIndex); + } else { + String expr = expressionString.substring(prefixIndex + prefix.length(), suffixIndex); + expr = expr.trim(); + if (expr.length()==0) { + throw new ParseException(expressionString, prefixIndex, "No expression defined within delimiter '" + + prefix + suffix + "' at character " + prefixIndex); + } + expressions.add(doParseExpression(expr, context)); + startIdx = suffixIndex + suffix.length(); + } + } else { + // no more ${expressions} found in string, add rest as static text + expressions.add(createLiteralExpression(context,expressionString.substring(startIdx))); + startIdx = expressionString.length(); + } + } + return expressions.toArray(new Expression[expressions.size()]); + } + + private Expression createLiteralExpression(ParserContext context, String text) { + return new LiteralExpression(text); + } + + /** + * Return true if the specified suffix can be found at the supplied position in the supplied expression string. + * @param expressionString the expression string which may contain the suffix + * @param pos the start position at which to check for the suffix + * @param suffix the suffix string + * @return + */ + private boolean isSuffixHere(String expressionString,int pos,String suffix) { + int suffixPosition = 0; + for (int i=0;i stack = new Stack(); + while (pos= 0) { @@ -28,7 +43,6 @@ public class PostgresTableMetaDataProvider extends GenericTableMetaDataProvider } } - @Override public String getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName) { return "RETURNING " + keyColumnName; diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterBatchUpdateUtils.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterBatchUpdateUtils.java index 4aefb450de..8f43da6bb8 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterBatchUpdateUtils.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterBatchUpdateUtils.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2011 the original author or authors. + * + * Licensed 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.springframework.jdbc.core.namedparam; import java.sql.PreparedStatement; diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/incrementer/SybaseAnywhereMaxValueIncrementer.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/incrementer/SybaseAnywhereMaxValueIncrementer.java index 39fe19db11..679ff4a1ce 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/incrementer/SybaseAnywhereMaxValueIncrementer.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/incrementer/SybaseAnywhereMaxValueIncrementer.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2011 the original author or authors. + * + * Licensed 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.springframework.jdbc.support.incrementer; import javax.sql.DataSource; @@ -57,7 +73,6 @@ public class SybaseAnywhereMaxValueIncrementer extends SybaseMaxValueIncrementer super(dataSource, incrementerName, columnName); } - @Override protected String getIncrementStatement() { return "insert into " + getIncrementerName() + " values(DEFAULT)"; diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/incrementer/SybaseMaxValueIncrementer.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/incrementer/SybaseMaxValueIncrementer.java index 9545a528fb..d8a30adfa5 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/incrementer/SybaseMaxValueIncrementer.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/support/incrementer/SybaseMaxValueIncrementer.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2011 the original author or authors. + * + * Licensed 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.springframework.jdbc.support.incrementer; import org.springframework.dao.DataAccessException; diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/HandlerExceptionResolverComposite.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/HandlerExceptionResolverComposite.java index d75b2e5bce..47463cad55 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/HandlerExceptionResolverComposite.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/HandlerExceptionResolverComposite.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2011 the original author or authors. + * + * Licensed 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.springframework.web.servlet.handler; import java.util.Collections; @@ -63,4 +79,4 @@ public class HandlerExceptionResolverComposite implements HandlerExceptionResolv return null; } -} \ No newline at end of file +} diff --git a/org.springframework.web/src/main/java/org/springframework/web/bind/annotation/PathVariable.java b/org.springframework.web/src/main/java/org/springframework/web/bind/annotation/PathVariable.java index aa77c24e71..40b157534e 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/bind/annotation/PathVariable.java +++ b/org.springframework.web/src/main/java/org/springframework/web/bind/annotation/PathVariable.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2011 the original author or authors. + * + * Licensed 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.springframework.web.bind.annotation; import java.lang.annotation.Documented; @@ -7,8 +23,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Annotation which indicates that a method parameter should be bound to a URI template variable. Supported for {@link - * RequestMapping} annotated handler methods in Servlet environments. + * Annotation which indicates that a method parameter should be bound to a URI template + * variable. Supported for {@link RequestMapping} annotated handler methods in Servlet + * environments. * * @author Arjen Poutsma * @see RequestMapping