diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2007-09-19 23:29:44 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2007-09-19 23:29:44 +0000 |
| commit | 05b3bf8f25b004ec8761c4d52a6740f60cbd9d2d (patch) | |
| tree | 8c0e7030d95ec59cc409669ac091edf518fc869c | |
| parent | 7ac52b8288273de98f3e97ee8e34776a61034bfc (diff) | |
| download | qpid-python-05b3bf8f25b004ec8761c4d52a6740f60cbd9d2d.tar.gz | |
merged the qpidity.url classes in to qpid.url and deleted qpidity.url
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@577464 13f79535-47bb-0310-9956-ffa450edef68
15 files changed, 54 insertions, 317 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java index 1728ab69f7..fc8f0a1a6f 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java @@ -64,8 +64,8 @@ import org.apache.qpid.jms.ConnectionListener; import org.apache.qpid.jms.ConnectionURL; import org.apache.qpid.jms.FailoverPolicy; import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.url.QpidURL; import org.apache.qpid.url.URLSyntaxException; -import org.apache.qpidity.url.QpidURL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/java/client/src/main/java/org/apache/qpidity/naming/PropertiesFileInitialContextFactory.java b/java/client/src/main/java/org/apache/qpidity/naming/PropertiesFileInitialContextFactory.java index 002263ce71..806ab284de 100644 --- a/java/client/src/main/java/org/apache/qpidity/naming/PropertiesFileInitialContextFactory.java +++ b/java/client/src/main/java/org/apache/qpidity/naming/PropertiesFileInitialContextFactory.java @@ -5,9 +5,9 @@ * 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 @@ -19,13 +19,13 @@ package org.apache.qpidity.naming; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.apache.qpid.url.BindingURLImpl; +import org.apache.qpid.url.QpidBindingURL; import org.apache.qpidity.njms.ConnectionFactoryImpl; import org.apache.qpidity.njms.DestinationImpl; import org.apache.qpidity.njms.QueueImpl; import org.apache.qpidity.njms.TopicImpl; -import org.apache.qpidity.url.BindingURLImpl; -import org.apache.qpidity.url.URLSyntaxException; -import org.apache.qpidity.url.BindingURL; +import org.apache.qpid.url.URLSyntaxException; import org.apache.qpidity.QpidException; import javax.naming.spi.InitialContextFactory; @@ -47,7 +47,7 @@ import java.net.MalformedURLException; /** * This is an implementation of InitialContextFactory that uses a default jndi.properties file. - * + * */ public class PropertiesFileInitialContextFactory implements InitialContextFactory { @@ -198,7 +198,7 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor */ protected Destination createDestination(String bindingURL) { - BindingURL binding; + QpidBindingURL binding; try { binding = new BindingURLImpl(bindingURL); @@ -231,9 +231,9 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor { result = new QueueImpl((String) value); } - else if (value instanceof BindingURL) + else if (value instanceof QpidBindingURL) { - result = new QueueImpl((BindingURL) value); + result = new QueueImpl((QpidBindingURL) value); } } catch (QpidException e) @@ -255,9 +255,9 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor { return new TopicImpl((String) value); } - else if (value instanceof BindingURL) + else if (value instanceof QpidBindingURL) { - return new TopicImpl((BindingURL) value); + return new TopicImpl((QpidBindingURL) value); } } catch (QpidException e) diff --git a/java/client/src/main/java/org/apache/qpidity/nclient/Client.java b/java/client/src/main/java/org/apache/qpidity/nclient/Client.java index ff05e40f20..14c6d0732a 100644 --- a/java/client/src/main/java/org/apache/qpidity/nclient/Client.java +++ b/java/client/src/main/java/org/apache/qpidity/nclient/Client.java @@ -5,6 +5,7 @@ import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import org.apache.qpid.url.QpidURL; import org.apache.qpidity.BrokerDetails; import org.apache.qpidity.ErrorCode; import org.apache.qpidity.QpidException; @@ -18,7 +19,6 @@ import org.apache.qpidity.transport.ConnectionEvent; import org.apache.qpidity.transport.ProtocolHeader; import org.apache.qpidity.transport.SessionDelegate; import org.apache.qpidity.transport.network.mina.MinaHandler; -import org.apache.qpidity.url.QpidURL; public class Client implements org.apache.qpidity.nclient.Connection diff --git a/java/client/src/main/java/org/apache/qpidity/nclient/Connection.java b/java/client/src/main/java/org/apache/qpidity/nclient/Connection.java index c11c8a04e0..d6ce25776b 100644 --- a/java/client/src/main/java/org/apache/qpidity/nclient/Connection.java +++ b/java/client/src/main/java/org/apache/qpidity/nclient/Connection.java @@ -18,8 +18,8 @@ */ package org.apache.qpidity.nclient; +import org.apache.qpid.url.QpidURL; import org.apache.qpidity.QpidException; -import org.apache.qpidity.url.QpidURL; /** * This represents a physical connection to a broker. diff --git a/java/client/src/main/java/org/apache/qpidity/njms/ConnectionFactoryImpl.java b/java/client/src/main/java/org/apache/qpidity/njms/ConnectionFactoryImpl.java index 23ddf1f2e0..c1d7c07209 100644 --- a/java/client/src/main/java/org/apache/qpidity/njms/ConnectionFactoryImpl.java +++ b/java/client/src/main/java/org/apache/qpidity/njms/ConnectionFactoryImpl.java @@ -4,11 +4,11 @@ import javax.jms.*; import javax.naming.*; import javax.naming.spi.ObjectFactory; +import org.apache.qpid.url.BindingURLImpl; +import org.apache.qpid.url.QpidURL; +import org.apache.qpid.url.QpidURLImpl; import org.apache.qpidity.QpidException; import org.apache.qpidity.BrokerDetails; -import org.apache.qpidity.url.QpidURLImpl; -import org.apache.qpidity.url.QpidURL; -import org.apache.qpidity.url.BindingURLImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/java/client/src/main/java/org/apache/qpidity/njms/ConnectionImpl.java b/java/client/src/main/java/org/apache/qpidity/njms/ConnectionImpl.java index e1ad6eb991..6e90a2a4cd 100644 --- a/java/client/src/main/java/org/apache/qpidity/njms/ConnectionImpl.java +++ b/java/client/src/main/java/org/apache/qpidity/njms/ConnectionImpl.java @@ -33,8 +33,8 @@ import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicSession; +import org.apache.qpid.url.QpidURL; import org.apache.qpidity.QpidException; -import org.apache.qpidity.url.QpidURL; import org.apache.qpidity.nclient.Client; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/java/client/src/main/java/org/apache/qpidity/njms/DestinationImpl.java b/java/client/src/main/java/org/apache/qpidity/njms/DestinationImpl.java index 247a41255e..c4111db790 100644 --- a/java/client/src/main/java/org/apache/qpidity/njms/DestinationImpl.java +++ b/java/client/src/main/java/org/apache/qpidity/njms/DestinationImpl.java @@ -5,9 +5,9 @@ * 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 @@ -18,9 +18,9 @@ package org.apache.qpidity.njms; import org.apache.qpidity.QpidException; -import org.apache.qpidity.url.BindingURL; -import org.apache.qpidity.url.BindingURLImpl; -import org.apache.qpidity.url.URLSyntaxException; +import org.apache.qpid.url.URLSyntaxException; +import org.apache.qpid.url.QpidBindingURL; +import org.apache.qpid.url.BindingURLImpl; import org.apache.qpid.url.URLHelper; import javax.jms.Destination; @@ -68,13 +68,13 @@ public class DestinationImpl implements Destination, Referenceable * Indicates whether this destination is durable */ protected boolean _isDurable; - + protected String _routingKey; /** * The biding URL used to create this destiantion */ - protected BindingURL _url; + protected QpidBindingURL _url; //--- Constructor @@ -90,14 +90,14 @@ public class DestinationImpl implements Destination, Referenceable * @param binding The URL * @throws QpidException If the URL is not valid */ - public DestinationImpl(BindingURL binding) throws QpidException + public DestinationImpl(QpidBindingURL binding) throws QpidException { _exchangeName = binding.getExchangeName(); _exchangeType = binding.getExchangeClass(); _destinationName = binding.getDestinationName(); - _isExclusive = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_EXCLUSIVE)); - _isAutoDelete = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_AUTODELETE)); - _isDurable = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_DURABLE)); + _isExclusive = Boolean.parseBoolean(binding.getOption(QpidBindingURL.OPTION_EXCLUSIVE)); + _isAutoDelete = Boolean.parseBoolean(binding.getOption(QpidBindingURL.OPTION_AUTODELETE)); + _isDurable = Boolean.parseBoolean(binding.getOption(QpidBindingURL.OPTION_DURABLE)); _queueName = binding.getQueueName(); _routingKey = binding.getQueueName(); _url = binding; @@ -179,7 +179,7 @@ public class DestinationImpl implements Destination, Referenceable { return _routingKey; } - + /** * Indicates whether this destination is Durable. * @@ -226,19 +226,19 @@ public class DestinationImpl implements Destination, Referenceable sb.append('?'); if (_isDurable) { - sb.append(org.apache.qpid.url.BindingURL.OPTION_DURABLE); + sb.append(org.apache.qpid.url.QpidBindingURL.OPTION_DURABLE); sb.append("='true'"); sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR); } if (_isExclusive) { - sb.append(org.apache.qpid.url.BindingURL.OPTION_EXCLUSIVE); + sb.append(org.apache.qpid.url.QpidBindingURL.OPTION_EXCLUSIVE); sb.append("='true'"); sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR); } if (_isAutoDelete) { - sb.append(org.apache.qpid.url.BindingURL.OPTION_AUTODELETE); + sb.append(org.apache.qpid.url.QpidBindingURL.OPTION_AUTODELETE); sb.append("='true'"); sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR); } diff --git a/java/client/src/main/java/org/apache/qpidity/njms/QueueImpl.java b/java/client/src/main/java/org/apache/qpidity/njms/QueueImpl.java index 43e8e9e43f..678a350c35 100644 --- a/java/client/src/main/java/org/apache/qpidity/njms/QueueImpl.java +++ b/java/client/src/main/java/org/apache/qpidity/njms/QueueImpl.java @@ -5,9 +5,9 @@ * 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 @@ -17,9 +17,9 @@ */ package org.apache.qpidity.njms; +import org.apache.qpid.url.QpidBindingURL; import org.apache.qpidity.QpidException; import org.apache.qpidity.transport.Option; -import org.apache.qpidity.url.BindingURL; import org.apache.qpidity.exchange.ExchangeDefaults; import javax.jms.Queue; @@ -30,7 +30,7 @@ import javax.jms.JMSException; */ public class QueueImpl extends DestinationImpl implements Queue { - //--- Constructor + //--- Constructor /** * Create a new QueueImpl with a given name. * @@ -58,7 +58,7 @@ public class QueueImpl extends DestinationImpl implements Queue * @param binding The URL * @throws QpidException If the URL is not valid */ - protected QueueImpl(SessionImpl session, BindingURL binding) throws QpidException + protected QueueImpl(SessionImpl session, QpidBindingURL binding) throws QpidException { super(binding); registerQueue(session, false); @@ -70,7 +70,7 @@ public class QueueImpl extends DestinationImpl implements Queue * @param binding The URL * @throws QpidException If the URL is not valid */ - public QueueImpl(BindingURL binding) throws QpidException + public QueueImpl(QpidBindingURL binding) throws QpidException { super(binding); } diff --git a/java/client/src/main/java/org/apache/qpidity/njms/TopicImpl.java b/java/client/src/main/java/org/apache/qpidity/njms/TopicImpl.java index fc6ea08897..2fcd6e4651 100644 --- a/java/client/src/main/java/org/apache/qpidity/njms/TopicImpl.java +++ b/java/client/src/main/java/org/apache/qpidity/njms/TopicImpl.java @@ -5,9 +5,9 @@ * 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 @@ -17,10 +17,10 @@ */ package org.apache.qpidity.njms; +import org.apache.qpid.url.QpidBindingURL; import org.apache.qpidity.QpidException; import org.apache.qpidity.exchange.ExchangeDefaults; import org.apache.qpidity.transport.Option; -import org.apache.qpidity.url.BindingURL; import javax.jms.Topic; import java.util.UUID; @@ -78,7 +78,7 @@ public class TopicImpl extends DestinationImpl implements Topic * @param binding The URL * @throws QpidException If the URL is not valid */ - protected TopicImpl(SessionImpl session, BindingURL binding) throws QpidException + protected TopicImpl(SessionImpl session, QpidBindingURL binding) throws QpidException { super(binding); checkTopicExists(session); @@ -91,7 +91,7 @@ public class TopicImpl extends DestinationImpl implements Topic * @param binding The URL * @throws QpidException If the URL is not valid */ - public TopicImpl(BindingURL binding) throws QpidException + public TopicImpl(QpidBindingURL binding) throws QpidException { super(binding); } @@ -119,9 +119,9 @@ public class TopicImpl extends DestinationImpl implements Topic session.getQpidSession().exchangeDeclare(_exchangeName, _exchangeType, null, null, Option.PASSIVE); // wait for the broker response System.out.println("Checking for exchange"); - + session.getQpidSession().sync(); - + System.out.println("Calling sync()"); // todo get the exception } diff --git a/java/common/src/main/java/org/apache/qpidity/url/BindingURLImpl.java b/java/common/src/main/java/org/apache/qpid/url/BindingURLImpl.java index 427e0f1413..2cf035f601 100644 --- a/java/common/src/main/java/org/apache/qpidity/url/BindingURLImpl.java +++ b/java/common/src/main/java/org/apache/qpid/url/BindingURLImpl.java @@ -5,9 +5,9 @@ * 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 @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.qpidity.url; +package org.apache.qpid.url; import org.apache.qpidity.exchange.ExchangeDefaults; import org.slf4j.LoggerFactory; @@ -25,7 +25,7 @@ import java.util.HashMap; import java.net.URI; import java.net.URISyntaxException; -public class BindingURLImpl implements BindingURL +public class BindingURLImpl implements QpidBindingURL { private static final Logger _logger = LoggerFactory.getLogger(BindingURLImpl.class); diff --git a/java/common/src/main/java/org/apache/qpidity/url/BindingURL.java b/java/common/src/main/java/org/apache/qpid/url/QpidBindingURL.java index a795b05b22..00edbf1bc3 100644 --- a/java/common/src/main/java/org/apache/qpidity/url/BindingURL.java +++ b/java/common/src/main/java/org/apache/qpid/url/QpidBindingURL.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.qpidity.url; +package org.apache.qpid.url; import org.apache.qpid.framing.AMQShortString; @@ -23,7 +23,7 @@ import org.apache.qpid.framing.AMQShortString; Binding URL format: <exch_class>://<exch_name>/[<destination>]/[<queue>]?<option>='<value>'[,<option>='<value>']* */ -public interface BindingURL +public interface QpidBindingURL { public static final String OPTION_EXCLUSIVE = "exclusive"; public static final String OPTION_AUTODELETE = "autodelete"; diff --git a/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java b/java/common/src/main/java/org/apache/qpid/url/QpidURL.java index 579c13a4eb..1d94b31de2 100644 --- a/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java +++ b/java/common/src/main/java/org/apache/qpid/url/QpidURL.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.qpidity.url; +package org.apache.qpid.url; import org.apache.qpidity.BrokerDetails; diff --git a/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java b/java/common/src/main/java/org/apache/qpid/url/QpidURLImpl.java index 20d5730d4f..b4a55e2bf4 100644 --- a/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java +++ b/java/common/src/main/java/org/apache/qpid/url/QpidURLImpl.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.qpidity.url; +package org.apache.qpid.url; import org.apache.qpidity.BrokerDetails; import org.apache.qpidity.BrokerDetailsImpl; diff --git a/java/common/src/main/java/org/apache/qpidity/url/URLHelper.java b/java/common/src/main/java/org/apache/qpidity/url/URLHelper.java deleted file mode 100644 index eba1b0bbeb..0000000000 --- a/java/common/src/main/java/org/apache/qpidity/url/URLHelper.java +++ /dev/null @@ -1,169 +0,0 @@ -/* 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.qpidity.url; - -import java.util.HashMap; - -public class URLHelper -{ - public static char DEFAULT_OPTION_SEPERATOR = '&'; - public static char ALTERNATIVE_OPTION_SEPARATOR = ','; - public static char BROKER_SEPARATOR = ';'; - - public static void parseOptions(HashMap<String, String> optionMap, String options) throws URLSyntaxException - { - // options looks like this - // brokerlist='tcp://host:port?option='value',option='value';vm://:3/virtualpath?option='value'',failover='method?option='value',option='value'' - - if ((options == null) || (options.indexOf('=') == -1)) - { - return; - } - - int optionIndex = options.indexOf('='); - - String option = options.substring(0, optionIndex); - - int length = options.length(); - - int nestedQuotes = 0; - - // to store index of final "'" - int valueIndex = optionIndex; - - // Walk remainder of url. - while ((nestedQuotes > 0) || (valueIndex < length)) - { - valueIndex++; - - if (valueIndex >= length) - { - break; - } - - if (options.charAt(valueIndex) == '\'') - { - if ((valueIndex + 1) < options.length()) - { - if ((options.charAt(valueIndex + 1) == DEFAULT_OPTION_SEPERATOR) - || (options.charAt(valueIndex + 1) == ALTERNATIVE_OPTION_SEPARATOR) - || (options.charAt(valueIndex + 1) == BROKER_SEPARATOR) - || (options.charAt(valueIndex + 1) == '\'')) - { - nestedQuotes--; - - if (nestedQuotes == 0) - { - // We've found the value of an option - break; - } - } - else - { - nestedQuotes++; - } - } - else - { - // We are at the end of the string - // Check to see if we are corectly closing quotes - if (options.charAt(valueIndex) == '\'') - { - nestedQuotes--; - } - - break; - } - } - } - - if ((nestedQuotes != 0) || (valueIndex < (optionIndex + 2))) - { - int sepIndex = 0; - - // Try and identify illegal separator character - if (nestedQuotes > 1) - { - for (int i = 0; i < nestedQuotes; i++) - { - sepIndex = options.indexOf('\'', sepIndex); - sepIndex++; - } - } - - if ((sepIndex >= options.length()) || (sepIndex == 0)) - { - throw parseError(valueIndex, "Unterminated option", options); - } - else - { - throw parseError(sepIndex, "Unterminated option. Possible illegal option separator:'" - + options.charAt(sepIndex) + "'", options); - } - } - - // optionIndex +2 to skip "='" - String value = options.substring(optionIndex + 2, valueIndex); - - optionMap.put(option, value); - - if (valueIndex < (options.length() - 1)) - { - // Recurse to get remaining options - parseOptions(optionMap, options.substring(valueIndex + 2)); - } - } - - public static URLSyntaxException parseError(int index, String error, String url) - { - return parseError(index, 1, error, url); - } - - public static URLSyntaxException parseError(int index, int length, String error, String url) - { - return new URLSyntaxException(url, error, index, length); - } - - public static String printOptions(HashMap<String, String> options) - { - if (options.isEmpty()) - { - return ""; - } - else - { - StringBuffer sb = new StringBuffer(); - sb.append('?'); - for (String key : options.keySet()) - { - sb.append(key); - - sb.append("='"); - - sb.append(options.get(key)); - - sb.append("'"); - sb.append(DEFAULT_OPTION_SEPERATOR); - } - - sb.deleteCharAt(sb.length() - 1); - - return sb.toString(); - } - } -} diff --git a/java/common/src/main/java/org/apache/qpidity/url/URLSyntaxException.java b/java/common/src/main/java/org/apache/qpidity/url/URLSyntaxException.java deleted file mode 100644 index bc65b70d14..0000000000 --- a/java/common/src/main/java/org/apache/qpidity/url/URLSyntaxException.java +++ /dev/null @@ -1,94 +0,0 @@ -/* 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.qpidity.url; - -import java.net.URISyntaxException; - -public class URLSyntaxException extends URISyntaxException -{ - private int _length; - - public URLSyntaxException(String url, String error, int index, int length) - { - super(url, error, index); - - _length = length; - } - - private static String getPositionString(int index, int length) - { - StringBuffer sb = new StringBuffer(index + 1); - - for (int i = 0; i < index; i++) - { - sb.append(" "); - } - - if (length > -1) - { - for (int i = 0; i < length; i++) - { - sb.append('^'); - } - } - - return sb.toString(); - } - - - public String toString() - { - StringBuffer sb = new StringBuffer(); - - sb.append(getReason()); - - if (getIndex() > -1) - { - if (_length != -1) - { - sb.append(" between indicies "); - sb.append(getIndex()); - sb.append(" and "); - sb.append(_length); - } - else - { - sb.append(" at index "); - sb.append(getIndex()); - } - } - - sb.append(" "); - if (getIndex() != -1) - { - sb.append("\n"); - } - - sb.append(getInput()); - - if (getIndex() != -1) - { - sb.append("\n"); - sb.append(getPositionString(getIndex(), _length)); - } - - return sb.toString(); - } - - -} |
