├── ch-commons-gsm ├── .gitignore ├── Makefile ├── README.md └── src │ ├── main │ └── java │ │ └── com │ │ └── cloudhopper │ │ └── commons │ │ └── gsm │ │ ├── Ton.java │ │ └── Npi.java │ └── test │ └── java │ └── com │ └── cloudhopper │ └── commons │ └── gsm │ └── demo │ └── DataCodingMain.java ├── ch-sxmp ├── .gitignore ├── Makefile ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── cloudhopper │ │ │ └── sxmp │ │ │ ├── DeliverResponse.java │ │ │ ├── SubmitResponse.java │ │ │ ├── util │ │ │ └── ToStringUtil.java │ │ │ ├── DeliveryReportResponse.java │ │ │ ├── PartialOperation.java │ │ │ ├── ErrorResponse.java │ │ │ ├── DeliverRequest.java │ │ │ ├── SxmpProcessor.java │ │ │ ├── servlet │ │ │ └── HttpStatusCodeException.java │ │ │ ├── TextEncoding.java │ │ │ ├── Application.java │ │ │ ├── DeliveryStatus.java │ │ │ ├── Account.java │ │ │ └── SubmitRequest.java │ ├── test │ │ └── resources │ │ │ └── logback-test.xml │ └── demo │ │ └── java │ │ └── com │ │ └── cloudhopper │ │ └── sxmp │ │ └── SenderMain.java └── README ├── ch-commons-charset ├── .gitignore ├── Makefile └── src │ ├── test │ └── java │ │ └── com │ │ └── cloudhopper │ │ └── commons │ │ └── charset │ │ ├── demo │ │ ├── Charset5Main.java │ │ ├── Charset4Main.java │ │ ├── Charset6Main.java │ │ ├── PrintGSMMain.java │ │ └── Charset2Main.java │ │ └── UTF8CharsetTest.java │ └── main │ └── java │ └── com │ └── cloudhopper │ └── commons │ └── charset │ ├── ISO88591Charset.java │ ├── ISO885915Charset.java │ ├── UCS2Charset.java │ ├── PackedGSMCharset.java │ ├── UTF8Charset.java │ └── UCS2LECharset.java ├── ch-commons-util ├── .gitignore ├── Makefile ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── cloudhopper │ │ │ └── commons │ │ │ └── util │ │ │ ├── windowing │ │ │ ├── DuplicateKeyException.java │ │ │ ├── OfferTimeoutException.java │ │ │ ├── WindowListener.java │ │ │ └── PendingOfferAbortedException.java │ │ │ ├── time │ │ │ ├── DateTimeDuration.java │ │ │ ├── DateTimeYear.java │ │ │ ├── DateTimeDay.java │ │ │ ├── DateTimeMonth.java │ │ │ ├── DateTimeHour.java │ │ │ └── DateTimeFiveMinutes.java │ │ │ ├── AddressFormatException.java │ │ │ ├── NameValue.java │ │ │ ├── MetaFieldInfo.java │ │ │ ├── SubstitutionException.java │ │ │ ├── BufferException.java │ │ │ ├── BufferSizeException.java │ │ │ ├── BufferIsFullException.java │ │ │ ├── BufferIsEmptyException.java │ │ │ ├── filefilter │ │ │ └── CompositeFileFilter.java │ │ │ ├── annotation │ │ │ └── MetaField.java │ │ │ ├── EnvironmentException.java │ │ │ ├── FileAlreadyExistsException.java │ │ │ ├── codec │ │ │ └── URLEncoderOutputStream.java │ │ │ ├── RandomUtil.java │ │ │ └── CountingRejectedExecutionHandler.java │ └── test │ │ ├── resources │ │ └── logback-test.xml │ │ └── java │ │ └── com │ │ └── cloudhopper │ │ └── commons │ │ └── util │ │ ├── demo │ │ ├── RandomUtilMain.java │ │ ├── EnvironmentUtilMain.java │ │ └── URLParserMain.java │ │ ├── sample │ │ ├── InternetPerson.java │ │ ├── ServerConfigException.java │ │ ├── ServerConfig.java │ │ └── Person.java │ │ ├── RandomUtilTest.java │ │ └── RunningAverageTest.java └── README.md ├── ch-jetty ├── .gitignore ├── Makefile ├── README ├── ChangeLog └── src │ ├── test │ ├── resources │ │ └── logback.xml │ └── java │ │ └── com │ │ └── cloudhopper │ │ └── jetty │ │ └── demo │ │ └── HelloServlet.java │ └── main │ └── java │ └── com │ └── cloudhopper │ └── jetty │ └── JettyExecutorThreadPool.java ├── ch-commons-io ├── .gitignore ├── README ├── Makefile ├── src │ └── main │ │ └── java │ │ └── com │ │ └── cloudhopper │ │ └── commons │ │ └── io │ │ ├── IdGenerator.java │ │ ├── UUIDIdGenerator.java │ │ └── FileStoreException.java └── ChangeLog ├── ch-commons-locale ├── .gitignore ├── src │ └── main │ │ └── resources │ │ └── com │ │ └── cloudhopper │ │ └── commons │ │ └── locale │ │ └── new-e164.txt ├── README └── ChangeLog ├── ch-commons-rfs ├── .gitignore ├── ChangeLog └── src │ └── main │ └── java │ └── com │ └── cloudhopper │ └── commons │ └── rfs │ └── FileSystemException.java ├── ch-commons-sql ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── cloudhopper │ │ └── commons │ │ └── sql │ │ ├── c3p0 │ │ └── package-info.java │ │ ├── proxool │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── adapter │ │ ├── package-info.java │ │ └── BasicManagedDataSource.java │ │ ├── SQLConfigurationException.java │ │ ├── SQLMissingDependencyException.java │ │ ├── DataSourceProvider.java │ │ └── ManagedDataSourceMBean.java ├── TODO └── ChangeLog ├── ch-commons-xbean ├── .gitignore └── src │ ├── main │ └── java │ │ └── com │ │ └── cloudhopper │ │ └── commons │ │ ├── xbean │ │ ├── package-info.java │ │ ├── type │ │ │ ├── package-info.java │ │ │ ├── ByteTypeConverter.java │ │ │ ├── LongTypeConverter.java │ │ │ ├── ShortTypeConverter.java │ │ │ ├── FloatTypeConverter.java │ │ │ ├── DoubleTypeConverter.java │ │ │ ├── IntegerTypeConverter.java │ │ │ ├── StringTypeConverter.java │ │ │ ├── FileTypeConverter.java │ │ │ ├── FloatPrimitiveTypeConverter.java │ │ │ ├── DoublePrimitiveTypeConverter.java │ │ │ ├── URLTypeConverter.java │ │ │ ├── BooleanPrimitiveTypeConverter.java │ │ │ ├── BooleanTypeConverter.java │ │ │ ├── BytePrimitiveTypeConverter.java │ │ │ ├── IntegerPrimitiveTypeConverter.java │ │ │ └── ShortPrimitiveTypeConverter.java │ │ ├── TypeConverter.java │ │ ├── XmlBeanException.java │ │ ├── XPathNotFoundException.java │ │ ├── RootTagMismatchException.java │ │ ├── XmlBeanClassException.java │ │ ├── ConversionException.java │ │ ├── ConversionOverflowException.java │ │ ├── util │ │ │ └── NumberRadixResult.java │ │ ├── PropertyNotFoundException.java │ │ ├── PropertyPermissionException.java │ │ ├── PropertyConversionException.java │ │ ├── XmlBeanProperty.java │ │ ├── PropertyAlreadySetException.java │ │ ├── PropertyIsEmptyException.java │ │ ├── PropertyInvalidTypeException.java │ │ ├── PropertyNoAttributesExpectedException.java │ │ └── PropertyInvocationException.java │ │ └── xml │ │ ├── Version.java │ │ └── SimpleHandler.java │ └── test │ ├── resources │ └── log4j.properties │ └── java │ └── com │ └── cloudhopper │ └── commons │ └── xbean │ └── type │ └── URLTypeConverterTest.java ├── ch-httpclient-util ├── .gitignore ├── README ├── ChangeLog └── src │ └── main │ └── java │ └── com │ └── cloudhopper │ └── httpclient │ └── util │ └── DoNotVerifySSLCertificateTrustManager.java ├── .gitignore ├── .travis.yml ├── ch-commons-ssl ├── src │ └── test │ │ └── resources │ │ ├── keystore │ │ ├── stunnel.conf │ │ ├── server.crt │ │ └── server.key └── CHANGELOG.md ├── ch-maven-parent-oss └── README.md └── pom.xml /ch-commons-gsm/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ -------------------------------------------------------------------------------- /ch-sxmp/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ -------------------------------------------------------------------------------- /ch-commons-charset/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ -------------------------------------------------------------------------------- /ch-commons-util/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ -------------------------------------------------------------------------------- /ch-jetty/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | -------------------------------------------------------------------------------- /ch-commons-io/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | -------------------------------------------------------------------------------- /ch-commons-locale/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | -------------------------------------------------------------------------------- /ch-commons-rfs/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | -------------------------------------------------------------------------------- /ch-commons-sql/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | -------------------------------------------------------------------------------- /ch-commons-xbean/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | -------------------------------------------------------------------------------- /ch-httpclient-util/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *~ 3 | *.iml 4 | .idea/ 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | jdk: 4 | - openjdk7 5 | -------------------------------------------------------------------------------- /ch-commons-locale/src/main/resources/com/cloudhopper/commons/locale/new-e164.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ch-commons-ssl/src/test/resources/keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/twitter/cloudhopper-commons/HEAD/ch-commons-ssl/src/test/resources/keystore -------------------------------------------------------------------------------- /ch-sxmp/Makefile: -------------------------------------------------------------------------------- 1 | run-parser: 2 | mvn -e test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.sxmp.demo.ParserMain" -------------------------------------------------------------------------------- /ch-commons-gsm/Makefile: -------------------------------------------------------------------------------- 1 | datacoding: 2 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.gsm.demo.DataCodingMain" -------------------------------------------------------------------------------- /ch-jetty/Makefile: -------------------------------------------------------------------------------- 1 | run-server: 2 | mvn -e test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.jetty.demo.HttpServerMain" -Dexec.args="" 3 | -------------------------------------------------------------------------------- /ch-commons-ssl/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Cloudhopper by Twitter 2 | ============================ 3 | 4 | cloudhopper-commons-ssl 5 | ------------------------ 6 | 7 | ## 1.0.0 - 2014-03-17 8 | - Initial version moved from cloudhopper-smpp. 9 | -------------------------------------------------------------------------------- /ch-commons-io/README: -------------------------------------------------------------------------------- 1 | Cloudhopper, Inc. 2 | http://www.cloudhopper.com/ 3 | Commons IO Library 4 | -------------------------------------------------------------------------------- 5 | 6 | General IO utilities for Cloudhopper projects. 7 | -------------------------------------------------------------------------------- /ch-commons-locale/README: -------------------------------------------------------------------------------- 1 | Cloudhopper, Inc. 2 | http://www.cloudhopper.com/ 3 | Commons L10n Library 4 | -------------------------------------------------------------------------------- 5 | 6 | General localization utilities for Cloudhopper projects. 7 | -------------------------------------------------------------------------------- /ch-commons-ssl/src/test/resources/stunnel.conf: -------------------------------------------------------------------------------- 1 | client=no 2 | foreground=yes 3 | debug=7 4 | pid=/tmp/stunnel.pid 5 | cert=src/test/resources/server.crt 6 | key=src/test/resources/server.key 7 | [smpp] 8 | accept=2777 9 | connect=127.0.0.1:2776 10 | -------------------------------------------------------------------------------- /ch-jetty/README: -------------------------------------------------------------------------------- 1 | Common HTTP Server based on Jetty 2 | -------------------------------------------------------------------------------- 3 | 4 | Wrapper around Jetty HTTP Server that makes configuration easy and possible 5 | from a simple few configuration objects. -------------------------------------------------------------------------------- /ch-commons-io/Makefile: -------------------------------------------------------------------------------- 1 | run-fileserver: 2 | mvn -e test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.io.demo.FileServerMain" -Dexec.args="/tmp/ 2" 3 | 4 | run-idtest: 5 | mvn -e test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.io.demo.IdTestMain" -Dexec.args="" -------------------------------------------------------------------------------- /ch-maven-parent-oss/README.md: -------------------------------------------------------------------------------- 1 | Cloudhopper by Twitter 2 | ====================== 3 | 4 | cloudhopper-maven-parent-oss 5 | ---------------------------- 6 | 7 | Parent Maven POM used for all open source Cloudhopper-based projects. 8 | 9 | License 10 | ------- 11 | 12 | Copyright (C) 2010-2014 Twitter, Inc. 13 | 14 | This work is licensed under the Apache License, Version 2.0. See LICENSE for details. 15 | -------------------------------------------------------------------------------- /ch-commons-ssl/src/test/resources/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICATCCAWoCCQCEwdEo1Uc29TANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB 3 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 4 | cyBQdHkgTHRkMB4XDTEzMDQxMDIzNTI1M1oXDTE0MDQxMDIzNTI1M1owRTELMAkG 5 | A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 6 | IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAs9ao 7 | eqfWIKjMQ+hggOclu6/zftOrvoCcZ8HYoE5G2YOQuvT2zIcTDR5EHcMuhlkF/5SV 8 | ta4baG6EZdO/WE3sJcVjJ64/5gBAXAOzw+f/pNoPyEGnFzpJugKemy0WntdHZZ9h 9 | 83OO2iKdk1Oco+7qc7MFaItoQsempiQPniQa+uMCAwEAATANBgkqhkiG9w0BAQUF 10 | AAOBgQBxUQtSeudvSUFNZSR7QdW3Kh8Gb1+ay9LNnQ/rcW+5pXk88inHIIzIdjo9 11 | NUwhRNLRyQUzW7sHTOut5lEZpkkOTFopoa2lmwyw7pZqDoVm71aKmxoCK5nwC8t7 12 | O4cHK2mWeZ1moUuemdKQZFVMAGS8TBgTlCump311o/2qOzEZaw== 13 | -----END CERTIFICATE----- 14 | -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/c3p0/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes that implement C3P0 adapters. 3 | */ 4 | package com.cloudhopper.commons.sql.c3p0; 5 | 6 | /* 7 | * #%L 8 | * ch-commons-sql 9 | * %% 10 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 11 | * %% 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes for configuring Java objects via XML. 3 | */ 4 | package com.cloudhopper.commons.xbean; 5 | 6 | /* 7 | * #%L 8 | * ch-commons-xbean 9 | * %% 10 | * Copyright (C) 2012 Cloudhopper by Twitter 11 | * %% 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/proxool/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes that implement Proxool adapters. 3 | */ 4 | package com.cloudhopper.commons.sql.proxool; 5 | 6 | /* 7 | * #%L 8 | * ch-commons-sql 9 | * %% 10 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 11 | * %% 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /ch-commons-rfs/ChangeLog: -------------------------------------------------------------------------------- 1 | Cloudhopper, Inc. 2 | http://www.cloudhopper.com/ 3 | Commons Remote FileSystem Library 4 | -------------------------------------------------------------------------------- 5 | 1.3.0 - 2013-11-06 6 | * Upgrade parent pom from public 1.5 to oss 1.4 7 | * Upgrade ch-commons-util dependency to 6.0.0 8 | * Ported from log4j to slf4j 9 | 10 | 1.2.0 - 2011-09-18 11 | * Updated build. 12 | 13 | 1.1 - 2009-10-26 14 | * Added support for provider URIs to include name/value pairs as normal URL 15 | query parameters. 16 | * Added support for FTP active vs. passive modes. 17 | * Added mkdir feature for FTP to support create missing directories 18 | * Added support path starting with ~ so that the path is not changed to the 19 | root directory first. The relative path is from whatever directory the 20 | FTP server puts us in after logging in. 21 | 22 | 1.0 - 2009-06-25 23 | * Initial release 24 | -------------------------------------------------------------------------------- /ch-httpclient-util/README: -------------------------------------------------------------------------------- 1 | Cloudhopper, Inc. 2 | http://www.cloudhopper.com/ 3 | Apache Jakarta HttpClient 4.x Utility Library 4 | -------------------------------------------------------------------------------- 5 | 6 | To generate a keystore: 7 | 8 | keytool -keystore test.jks -genkey -keyalg RSA -alias server 9 | 10 | What is your first and last name? 11 | [System]: test.cloudhopper.lan 12 | What is the name of your organizational unit? 13 | [Network Operations]: 14 | What is the name of your organization? 15 | [Cloudhopper Inc]: 16 | What is the name of your City or Locality? 17 | [Seattle]: 18 | What is the name of your State or Province? 19 | [WA]: 20 | What is the two-letter country code for this unit? 21 | [US]: 22 | Is CN=test.cloudhopper.lan, OU=Network Operations, O=Cloudhopper Inc, L=Seattle, ST=WA, C=US correct? 23 | [no]: yes 24 | 25 | Enter key password for 26 | (RETURN if same as keystore password): 27 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes for converting Strings to Java types such as Integers. 3 | */ 4 | package com.cloudhopper.commons.xbean.type; 5 | 6 | /* 7 | * #%L 8 | * ch-commons-xbean 9 | * %% 10 | * Copyright (C) 2012 Cloudhopper by Twitter 11 | * %% 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | -------------------------------------------------------------------------------- /ch-commons-ssl/src/test/resources/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXQIBAAKBgQCz1qh6p9YgqMxD6GCA5yW7r/N+06u+gJxnwdigTkbZg5C69PbM 3 | hxMNHkQdwy6GWQX/lJW1rhtoboRl079YTewlxWMnrj/mAEBcA7PD5/+k2g/IQacX 4 | Okm6Ap6bLRae10dln2Hzc47aIp2TU5yj7upzswVoi2hCx6amJA+eJBr64wIDAQAB 5 | AoGALzCboxvZb1Z7yzH16L0+xIJGJbiLb4C2Ce/u1RnVM4x3dOeEv2SOVjnj699k 6 | nPJNRaSKqFLYdE3TxhiLNDO2TD5fhCHdwN+bczNLX7FH2LRGgVNi7WNGLcFOKXkp 7 | WPke9zxcqTT6QiCw9upa2VrzzMFK7mb1pYPaGDOktdraWBkCQQDa1KSQ5n3OL6ue 8 | xHS4Nl+AJhu0dtbaHD4/lKZMINbH5x/yZ8Jl0YI16cWf0ERfSqIjCWLybYaWp23D 9 | y36YHkh1AkEA0mKHzFMg/StWojLGOQmYS8SGEm6g5USOiovq2v5LYVN+kPpJj9qf 10 | ju6cPsfOuFnXpknw/x0dji0dKvHTAgSK9wJBAIwmRiN7SzVjeIHdhnd4c1+KiJHi 11 | zqWwEvn7hSoamhQ7ZU2FwI4fSUqoJua8px10mjTgTRvAo8MXBgiw6qoYMwUCQQC1 12 | hbIpx6f1CMmtFSYW3IJ9DUmo6a8FYkuimuq+nR6pEQNpT6rc5gM5rgM93+QrB8mb 13 | frzjQVnY7G/4N8KaQRUtAkAaJnEV2MFXgKdiE8uLuGnrRBjRovDxM93H3zjlTAaO 14 | fSkL6WL8/g2RYrw2/W4WNu8I9Eqh0XlqSelFQYLd5FQE 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Common utilities for configuring, creating, and managing a DataSource and 3 | * executing JDBC methods. 4 | */ 5 | package com.cloudhopper.commons.sql; 6 | 7 | /* 8 | * #%L 9 | * ch-commons-sql 10 | * %% 11 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 12 | * %% 13 | * Licensed under the Apache License, Version 2.0 (the "License"); 14 | * you may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * #L% 25 | */ 26 | -------------------------------------------------------------------------------- /ch-commons-io/src/main/java/com/cloudhopper/commons/io/IdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.io; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-io 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * ID generator. 25 | * @author garth 26 | */ 27 | public interface IdGenerator 28 | { 29 | 30 | public Id newId(); 31 | 32 | } -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/adapter/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Adapters for common SQL utility classes for various underlying implementations 3 | * such as C3P0 or Proxool. 4 | */ 5 | package com.cloudhopper.commons.sql.adapter; 6 | 7 | /* 8 | * #%L 9 | * ch-commons-sql 10 | * %% 11 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 12 | * %% 13 | * Licensed under the Apache License, Version 2.0 (the "License"); 14 | * you may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * #L% 25 | */ 26 | -------------------------------------------------------------------------------- /ch-commons-sql/TODO: -------------------------------------------------------------------------------- 1 | 2 | * Assign a random name to the datasource if its set to null -- might allow for 3 | a more zero-configuration setup. 4 | 5 | * Test cases for these scenarios: 6 | - basic configuration stuff? values are setup correctly? 7 | - parsing of bad JDBC URLs? 8 | - are required properties validated? 9 | - waiting for a connection and timing out (if pool is exhausted, check that 10 | it times-out properly) is this detectable in JMX? 11 | - what happens if the database connection pool fails -- does it eventually 12 | fix itself? is that somehow detectable in JMX? 13 | 14 | * Better aggregate JMX properties for determing if a pool is in "trouble" -- 15 | maybe some sort of simple warning or severe state. 16 | 17 | * Expose debugging properties 18 | 19 | * Expose logging properties 20 | 21 | * Some method of shutting down or destroying connection pools -- might need to 22 | implement some form of tracking 23 | 24 | * Support for statement caching configuration (in c3p0) -------------------------------------------------------------------------------- /ch-commons-io/ChangeLog: -------------------------------------------------------------------------------- 1 | Cloudhopper 2 | Commons IO Library 3 | -------------------------------------------------------------------------------- 4 | 2.3.0 - 2013-11-06 5 | * Upgrade parent pom from public 1.5 to oss 1.4 6 | * Upgrade ch-commons-util dependency to 6.0.0 7 | 8 | 2.2.2 - 2011-09-01 9 | * Upgrade parent pom from 1.0 to 1.5 10 | * New Version class now added with upgrade parent pom 11 | 12 | 2.2.1 - 2011-08-31 13 | * Close channels in SimpleNIOFileStore. We were leaking open file descriptors. 14 | 15 | 2.2 - 2011-08-11 16 | * Added metaData field to Id. 17 | 18 | 2.1 - 2011-07-06 19 | * Removed host from FileStore Id. Added size to Id metadata. 20 | * Removed file server and Netty dependency. 21 | 22 | 2.0 - 2011-06-14 23 | * New build process (from ant to maven) 24 | * Moved src/demo/java into src/test/java directory (for maven) 25 | * Many new classes to primarily support ch-flamingo. 26 | * Removed log4j dependendency - switched to SLF4J 27 | 28 | 1.0 - 2009-04-01 29 | * Initial release extracted from ch-commons-util 30 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/TypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Interface to convert String values to Java objects. 25 | * 26 | * @author joelauer 27 | */ 28 | public interface TypeConverter { 29 | 30 | public Object convert(String value) throws ConversionException; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /ch-commons-locale/ChangeLog: -------------------------------------------------------------------------------- 1 | Cloudhopper, Inc. 2 | http://www.cloudhopper.com/ 3 | Commons Locale Library 4 | -------------------------------------------------------------------------------- 5 | 1.5.0 - 2013-11-06 6 | * Upgrade parent pom from public 1.5 to oss 1.4 7 | * Upgrade ch-commons-util dependency to 6.0.0 8 | * Ported from log4j to slf4j 9 | 10 | 1.4.2 - 2012-02-17 11 | * Updated country codes for Yugoslavia and a few other countries. 12 | 13 | 1.4.1 - 2011-09-18 14 | * Updated build. 15 | 16 | 1.4 - 2009-07-15 17 | * Country.getName() now returns the short version of a country such as "Nigeria" 18 | instead of the long and useless "Nigeria, Republic of". There is now a 19 | new method called getLongName() that returns the former long name. 20 | 21 | 1.3 - 2009-07-12 22 | * Fixed numerous incorrect country mappings in E164 Country Codes. 23 | 24 | 1.2 - 2009-05-15 25 | * Added ability to lookup a country by its ISO2 value. 26 | 27 | 1.1 - 2009-05-15 28 | * Added E.164 Country Codes and Lookup Utility 29 | 30 | 1.0 - 2009-04-01 31 | * Initial release extracted from ch-commons-util 32 | -------------------------------------------------------------------------------- /ch-commons-util/Makefile: -------------------------------------------------------------------------------- 1 | 2 | encrypt: 3 | mvn test-compile exec:java -Dexec.classpathScope="test" exec:java -Dexec.mainClass="com.cloudhopper.commons.util.demo.EncryptUtilMain" -Dexec.args="providers" 4 | 5 | random: 6 | mvn test-compile exec:java -Dexec.classpathScope="test" exec:java -Dexec.mainClass="com.cloudhopper.commons.util.demo.RandomUtilMain" 7 | 8 | uptime: 9 | mvn test-compile exec:java -Dexec.classpathScope="test" exec:java -Dexec.mainClass="com.cloudhopper.commons.util.demo.UptimeMain" 10 | 11 | compression: 12 | mvn test-compile exec:java -Dexec.classpathScope="test" exec:java -Dexec.mainClass="com.cloudhopper.commons.util.demo.CompressionUtilMain" 13 | 14 | environment: 15 | mvn test-compile exec:java -Dexec.classpathScope="test" exec:java -Dexec.mainClass="com.cloudhopper.commons.util.demo.EnvironmentUtilMain" 16 | 17 | window: 18 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.util.demo.WindowMain" 19 | 20 | window2: 21 | mvn test-compile exec:java -Dexec.classpathScope="test" exec:java -Dexec.mainClass="com.cloudhopper.commons.util.demo.Window2Main" 22 | -------------------------------------------------------------------------------- /ch-httpclient-util/ChangeLog: -------------------------------------------------------------------------------- 1 | Cloudhopper, Inc. 2 | http://www.cloudhopper.com/ 3 | Apache Jakarta HttpClient 4.x Utility Library 4 | -------------------------------------------------------------------------------- 5 | 1.5.1 - 2015-02-06 6 | * Upgrade to org.apache.httpcomponents httpclient to 4.2.6 and httpcore to 4.2.5 7 | which removes deprecated methods and prepares for further version upgrades. 8 | 9 | 1.5.0 - 2013-11-15 10 | * Upgrade parent pom from public to oss 1.4 11 | * Upgrade to Maven Central version of httpclient 12 | * Upgrade to Maven Central version of grizzly-server 13 | * Added a runtime dependency to org.slf4j.jcl-over-slf4j for httpclient 14 | 15 | 1.4.1 - 2011-09-18 16 | * Updated build process. 17 | 18 | 1.4 - 2010-10-20 19 | * Added keystore and truststore support to HttpClientFactory 20 | 21 | 1.3 - 2010-10-15 22 | * Added keystore and truststore HTTPS scheme to SchemeFactory 23 | 24 | 1.2 - 2010-01-31 25 | * Added normal HTTPS scheme for SchemeFactory 26 | 27 | 1.1 - 2010-01-27 28 | * Added ability to handle multiple HTTP status codes as "expected" 29 | 30 | 1.0 - 2010-01-03 31 | * Initial release 32 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/DeliverResponse.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class DeliverResponse extends Response { 28 | 29 | public DeliverResponse() { 30 | super(Operation.Type.DELIVER); 31 | } 32 | 33 | @Override 34 | public void validate() throws SxmpErrorException { 35 | super.validate(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/SubmitResponse.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class SubmitResponse extends Response { 28 | 29 | public SubmitResponse() { 30 | super(Operation.Type.SUBMIT); 31 | } 32 | 33 | @Override 34 | public void validate() throws SxmpErrorException { 35 | super.validate(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/util/ToStringUtil.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp.util; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Utility for creating toString() methods. 25 | * 26 | * @author joelauer 27 | */ 28 | public class ToStringUtil { 29 | 30 | public static String nullSafe(Object obj) { 31 | if (obj == null) { 32 | return ""; 33 | } else { 34 | return obj.toString(); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ch-commons-io/src/main/java/com/cloudhopper/commons/io/UUIDIdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.io; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-io 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.UUID; 24 | 25 | /** 26 | * ID generator that produces a UUID. 27 | * @author garth 28 | */ 29 | public class UUIDIdGenerator 30 | implements IdGenerator 31 | { 32 | 33 | public UUIDIdGenerator() {} 34 | 35 | @Override 36 | public Id newId() { return new Id(UUID.randomUUID().toString()); } 37 | 38 | } -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/DeliveryReportResponse.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class DeliveryReportResponse extends Response { 28 | 29 | public DeliveryReportResponse() { 30 | super(Operation.Type.DELIVERY_REPORT); 31 | } 32 | 33 | @Override 34 | public void validate() throws SxmpErrorException { 35 | super.validate(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/XmlBeanException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Super class for any XmlBean exceptions. 25 | * @author joelauer 26 | */ 27 | public abstract class XmlBeanException extends Exception { 28 | 29 | public XmlBeanException(String msg) { 30 | super(msg); 31 | } 32 | 33 | public XmlBeanException(String msg, Throwable t) { 34 | super(msg, t); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xml/Version.java: -------------------------------------------------------------------------------- 1 | /** DO NOT EDIT THIS FILE. IT IS AUTO GENERATED BY MAVEN */ 2 | package com.cloudhopper.commons.xml; 3 | public final class Version { 4 | private static final String TIMESTAMP="20110918-1629"; 5 | private static final String VERSION="1.2.0"; 6 | private static final String NAME="ch-commons-xml"; 7 | private static final String VENDOR="cloudhopper"; 8 | private static final String LONG_VERSION="1.2.0 (Build @ 20110918-1629)"; 9 | /** Returns the library vendor such as "cloudhopper" */ 10 | static public String getVendor() { return VENDOR; } 11 | /** Returns the library build timestamp such as "20110918-1629" */ 12 | static public String getTimestamp() { return TIMESTAMP; } 13 | /** Returns the library name such as "ch-commons-xml" */ 14 | static public String getName() { return NAME; } 15 | /** Returns the library version such as "1.2.0" */ 16 | static public String getVersion() { return VERSION; } 17 | /** Returns a longer library version that includes the timestamp such as "1.2.0 (Build @ 20110918-1629)" */ 18 | static public String getLongVersion() { return LONG_VERSION; } 19 | } 20 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/PartialOperation.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * An operation that could only be partially parsed. 25 | * 26 | * @author joelauer 27 | */ 28 | public class PartialOperation extends Operation { 29 | 30 | public PartialOperation(Operation.Type value) { 31 | super(value, true); 32 | } 33 | 34 | @Override 35 | public void validate() throws SxmpErrorException { 36 | // do nothing 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/ByteTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | 25 | /** 26 | * Converts a String to a Byte. 27 | * @author joelauer 28 | */ 29 | public class ByteTypeConverter extends BytePrimitiveTypeConverter { 30 | 31 | @Override 32 | public Object convert(String value) throws ConversionException { 33 | return (Byte)super.convert(value); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/LongTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | 25 | /** 26 | * Converts a String to a Long. 27 | * @author joelauer 28 | */ 29 | public class LongTypeConverter extends LongPrimitiveTypeConverter { 30 | 31 | @Override 32 | public Object convert(String value) throws ConversionException { 33 | return (Long)super.convert(value); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/ShortTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | 25 | /** 26 | * Converts a String to a Short. 27 | * @author joelauer 28 | */ 29 | public class ShortTypeConverter extends ShortPrimitiveTypeConverter { 30 | 31 | @Override 32 | public Object convert(String value) throws ConversionException { 33 | return (Short)super.convert(value); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ch-jetty/ChangeLog: -------------------------------------------------------------------------------- 1 | Common HTTP Server based on Jetty 2 | -------------------------------------------------------------------------------- 3 | 1.1.3 - 2015-03-19 4 | * Added backwards compatibility because SSLv2Hello is disabled by default in Java >=7 5 | 6 | 1.1.2 - 2015-02-06 7 | * Added pass thru lifecycle status methods 8 | * Added more thread pool stats 9 | 10 | 1.1.1 - 2015-01-09 11 | * HttpConnectorConfiguration trackStats changed to statsEnabled. Changed default to true. 12 | * nonBlockingSocketsEnabled added to HttpConnectorConfiguration. Defaults to true. 13 | * Monitoring stats on the thread pool added to JettyHttpServer. 14 | * Figured out how to replicate Jetty7 statsOn with ConnectorStatistics. 15 | * Wrapped ExecutorThreadPool with a custom implemetation that exposes the ThreadPoolExecutor. 16 | 17 | 1.1.0 - 2015-01-05 18 | * Upgrade jetty to 9.2.6.v20141205 19 | * Ported to new Jetty 9 APIs 20 | 21 | 1.0.2 - 2013-11-06 22 | * Upgrade parent pom from public 1.5 to oss 1.4 23 | * Upgrade ch-commons-xbean dependency to 3.0.0 24 | * Upgrade jetty to org.eclipse.jetty 7.6.14.v20131031 25 | 26 | 1.0.1 - 2011-09-18 27 | * Updated build and license. 28 | 29 | 1.0.0 - 2011-09-12 30 | * Initial release relying on Jetty Server 7.4.2 31 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/FloatTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | 25 | /** 26 | * Converts a String to a Double. 27 | * 28 | * @author joelauer 29 | */ 30 | public class FloatTypeConverter extends FloatPrimitiveTypeConverter { 31 | 32 | @Override 33 | public Object convert(String value) throws ConversionException { 34 | return (Float)super.convert(value); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/DoubleTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | 25 | /** 26 | * Converts a String to a Double. 27 | * 28 | * @author joelauer 29 | */ 30 | public class DoubleTypeConverter extends DoublePrimitiveTypeConverter { 31 | 32 | @Override 33 | public Object convert(String value) throws ConversionException { 34 | return (Double)super.convert(value); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/IntegerTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | 25 | /** 26 | * Converts a String to an Integer. 27 | * @author joelauer 28 | */ 29 | public class IntegerTypeConverter extends IntegerPrimitiveTypeConverter { 30 | 31 | @Override 32 | public Object convert(String value) throws ConversionException { 33 | return (Integer)super.convert(value); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/ErrorResponse.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class ErrorResponse extends Response { 28 | 29 | public ErrorResponse(Operation.Type type, Integer errorCode, String errorMessage) { 30 | super(type); 31 | this.setErrorCode(errorCode); 32 | this.setErrorMessage(errorMessage); 33 | } 34 | 35 | @Override 36 | public void validate() throws SxmpErrorException { 37 | super.validate(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/StringTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | import com.cloudhopper.commons.xbean.TypeConverter; 25 | 26 | /** 27 | * Converts a String to a String. 28 | * @author joelauer 29 | */ 30 | public class StringTypeConverter implements TypeConverter { 31 | 32 | @Override 33 | public Object convert(String value) throws ConversionException { 34 | return value; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/XPathNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown if an xpath is not found in an xml document. 25 | * @author joelauer 26 | */ 27 | public class XPathNotFoundException extends XmlBeanException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | public XPathNotFoundException(String msg) { 31 | this(msg, null); 32 | } 33 | 34 | public XPathNotFoundException(String msg, Throwable t) { 35 | super(msg, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/windowing/DuplicateKeyException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.windowing; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when the key for a request already exists. 25 | * 26 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 27 | */ 28 | public class DuplicateKeyException extends Exception { 29 | static final long serialVersionUID = 1L; 30 | 31 | public DuplicateKeyException(String msg) { 32 | super(msg); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /ch-sxmp/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | System.err 25 | 26 | %-23d [%thread] %-5level %logger{32} - %m%n 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ch-commons-util/README.md: -------------------------------------------------------------------------------- 1 | Cloudhopper by Twitter 2 | ============================ 3 | 4 | cloudhopper-commons-util 5 | ------------------------ 6 | 7 | Utility Java classes commonly used across all Cloudhopper-based projects. 8 | 9 | Contributors 10 | ------------ 11 | 12 | Joe Lauer (Twitter: [@jjlauer](http://twitter.com/jjlauer)) 13 | 14 | Installation 15 | ------------ 16 | 17 | Library versions >= 6.0.0 are now published to the Maven Central Repository. 18 | Just add the following dependency to your project maven pom.xml: 19 | 20 | 21 | com.cloudhopper 22 | ch-commons-util 23 | [6.0.0,) 24 | 25 | 26 | Demo Code / Tutorials 27 | --------------------- 28 | 29 | There are numerous examples of how to use various parts of this library: 30 | 31 | src/test/java/com/cloudhopper/commons/util/demo 32 | 33 | To run some of the samples, there is a Makefile to simplify the syntax required 34 | by Maven: 35 | 36 | make uptime 37 | make window 38 | 39 | On Windows, you'd run: 40 | 41 | nmake uptime 42 | nmake window 43 | 44 | License 45 | ------- 46 | 47 | Copyright (C) 2010-2012 Twitter, Inc. 48 | 49 | This work is licensed under the Apache License, Version 2.0. See LICENSE for details. -------------------------------------------------------------------------------- /ch-commons-util/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | System.err 25 | 26 | %-23d [%thread] %-5level %logger{32} - %m%n 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/RootTagMismatchException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown if a root tag does not match a tag name provided. 25 | * @author joelauer 26 | */ 27 | public class RootTagMismatchException extends XmlBeanException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | public RootTagMismatchException(String msg) { 31 | this(msg, null); 32 | } 33 | 34 | public RootTagMismatchException(String msg, Throwable t) { 35 | super(msg, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/XmlBeanClassException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown if there is an exception during reflection or instantiation of a class. 25 | * @author joelauer 26 | */ 27 | public class XmlBeanClassException extends XmlBeanException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | public XmlBeanClassException(String msg) { 31 | this(msg, null); 32 | } 33 | 34 | public XmlBeanClassException(String msg, Throwable t) { 35 | super(msg, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xml/SimpleHandler.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xml; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.xml.sax.Attributes; 24 | import org.xml.sax.SAXException; 25 | 26 | /** 27 | * Interface for simple handling of XML. 28 | * 29 | * @author joelauer 30 | */ 31 | public interface SimpleHandler { 32 | 33 | public void startElement(int depth, String uri, String tag, Attributes attrs) throws SAXException; 34 | 35 | public void endElement(int depth, String uri, String tag, Attributes attrs, StringBuilder charBuffer) throws SAXException; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/time/DateTimeDuration.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.time; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | // java imports 24 | 25 | // my imports 26 | 27 | /** 28 | * Enumeration of a specific duration of time such as a Month, Year, Hour, etc. 29 | * 30 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 31 | */ 32 | public enum DateTimeDuration { 33 | YEAR, 34 | MONTH, 35 | DAY, 36 | HOUR, 37 | FIVE_MINUTES, 38 | MINUTE, 39 | SECOND, 40 | MILLISECOND; 41 | } 42 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/ConversionException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown by PropertyConverter classes when a String fails conversion to a 25 | * Java object. 26 | * 27 | * @author joelauer 28 | */ 29 | public class ConversionException extends Exception { 30 | private static final long serialVersionUID = 1L; 31 | 32 | public ConversionException(String msg) { 33 | super(msg); 34 | } 35 | 36 | public ConversionException(String msg, Throwable t) { 37 | super(msg, t); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/FileTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | import com.cloudhopper.commons.xbean.TypeConverter; 25 | import java.io.File; 26 | 27 | /** 28 | * Converts a String to a File. 29 | * 30 | * @author joelauer 31 | */ 32 | public class FileTypeConverter implements TypeConverter { 33 | 34 | @Override 35 | public Object convert(String value) throws ConversionException { 36 | return new File(value); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/ConversionOverflowException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when a property fails during conversion to a Java object. 25 | * @author joelauer 26 | */ 27 | public class ConversionOverflowException extends ConversionException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | public ConversionOverflowException(String msg) { 31 | this(msg, null); 32 | } 33 | 34 | public ConversionOverflowException(String msg, Throwable t) { 35 | super(msg, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/demo/RandomUtilMain.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | // java imports 24 | 25 | import com.cloudhopper.commons.util.RandomUtil; 26 | 27 | 28 | /** 29 | * 30 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 31 | */ 32 | public class RandomUtilMain { 33 | 34 | public static void main(String[] args) { 35 | String string0 = RandomUtil.generateString(8); 36 | System.out.println("Random 8-Char String: " + string0); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/AddressFormatException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when an invalid Address format is used. 25 | * 26 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 27 | */ 28 | public class AddressFormatException extends IllegalArgumentException { 29 | private static final long serialVersionUID = 1L; 30 | 31 | public AddressFormatException(String msg) { 32 | super(msg); 33 | } 34 | 35 | public AddressFormatException(String msg, Throwable t) { 36 | super(msg, t); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/NameValue.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Represents a NameValue with generics. 25 | * 26 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 27 | */ 28 | public class NameValue { 29 | private N name; 30 | private V value; 31 | 32 | public NameValue(N name, V value) { 33 | this.name = name; 34 | this.value = value; 35 | } 36 | 37 | public N getName() { 38 | return name; 39 | } 40 | 41 | public V getValue() { 42 | return value; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ch-commons-io/src/main/java/com/cloudhopper/commons/io/FileStoreException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.io; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-io 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * FileStore exception. 27 | * @author garth 28 | */ 29 | public class FileStoreException 30 | extends IOException 31 | { 32 | 33 | public FileStoreException() { 34 | super(); 35 | } 36 | 37 | public FileStoreException(String message) { 38 | super(message); 39 | } 40 | 41 | public FileStoreException(String message, Throwable cause) { 42 | super(message, cause); 43 | } 44 | 45 | public FileStoreException(Throwable cause) { 46 | super(cause); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/util/NumberRadixResult.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Result when using the NumberRadixUtil class. 25 | * 26 | * @author joelauer 27 | */ 28 | public class NumberRadixResult { 29 | 30 | private final String number; 31 | private final int radix; 32 | 33 | public NumberRadixResult(String number, int radix) { 34 | this.number = number; 35 | this.radix = radix; 36 | } 37 | 38 | public String getNumber() { 39 | return this.number; 40 | } 41 | 42 | public int getRadix() { 43 | return this.radix; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /ch-commons-sql/ChangeLog: -------------------------------------------------------------------------------- 1 | Cloudhopper, Inc. 2 | http://www.cloudhopper.com/ 3 | Commons Sql Library 4 | -------------------------------------------------------------------------------- 5 | 1.3.2 - 2016-03-17 6 | * Upgrade Vertica driver to new namespace used by 6.x+: com.vertica.jdbc.Driver 7 | 8 | 1.3.1 - 2014-03-17 9 | * Added HSQLDB to DatabaseVendor 10 | * password is no longer a required parameter in DataSourceConfiguration 11 | 12 | 1.3.0 - 2013-11-06 13 | * Upgrade parent pom from public 1.5 to oss 1.4 14 | * Upgrade ch-commons-util dependency to 6.0.0 15 | * Upgrade ch-commons-xbean dependency to 3.0.0 16 | * Ported from log4j to slf4j 17 | * Switched to CH distribution of proxool 0.9.1 in Maven Central 18 | * Added a runtime dependency to org.slf4j.jcl-over-slf4j for proxool 19 | 20 | 1.2.0 - 2012-05-17 21 | * Addded support for "vertica" driver and vendor. 22 | * Updated ch-commons-util dependency from 5.1.1 to 5.1.2 23 | * Upgraded logback-classic dependency from 0.9.28 to 1.0.1 24 | * Upgraded logback-core dependency from 0.9.28 to 1.0.1 25 | * Upgraded log4j-over-slf4j dependency from 1.6.1 to 1.6.4 26 | * Upgraded slf4j-api dependency from 1.6.1 to 1.6.4 27 | 28 | 1.1.0 - 2011-10-19 29 | * Added support for "postgresql" driver and vendor. 30 | 31 | 1.0.1 - 2011-09-18 32 | * Updated build. 33 | 34 | 1.0 - 2009-06-29 35 | * Initial release extracted from ch-commons-util 36 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/DeliverRequest.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class DeliverRequest extends MessageRequest { 28 | 29 | public DeliverRequest() { 30 | super(Operation.Type.DELIVER); 31 | } 32 | 33 | public DeliverResponse createResponse() throws SxmpErrorException { 34 | DeliverResponse deliverResp = new DeliverResponse(); 35 | deliverResp.setReferenceId(this.getReferenceId()); 36 | return deliverResp; 37 | } 38 | 39 | @Override 40 | public void validate() throws SxmpErrorException { 41 | super.validate(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/SxmpProcessor.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Interface for processing SXMP requests. 25 | * 26 | * @author joelauer 27 | */ 28 | public interface SxmpProcessor { 29 | 30 | public boolean authenticate(Account account) throws SxmpErrorException; 31 | 32 | public SubmitResponse submit(Account account, SubmitRequest submitRequest) throws SxmpErrorException; 33 | 34 | public DeliverResponse deliver(Account account, DeliverRequest deliverRequest) throws SxmpErrorException; 35 | 36 | public DeliveryReportResponse deliveryReport(Account account, DeliveryReportRequest deliveryRequest) throws SxmpErrorException; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/windowing/OfferTimeoutException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.windowing; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown if an offer cannot be accepted within a specified amount of time. 25 | * 26 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 27 | */ 28 | public class OfferTimeoutException extends Exception { 29 | static final long serialVersionUID = 1L; 30 | 31 | public OfferTimeoutException(String msg) { 32 | super(msg); 33 | } 34 | 35 | public OfferTimeoutException(String msg, Throwable t) { 36 | super(msg, t); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/MetaFieldInfo.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.util.annotation.Level; 24 | 25 | /** 26 | * Simple class to display a counter's name, value, and description based on 27 | * current values and annotations. 28 | * 29 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 30 | */ 31 | public class MetaFieldInfo { 32 | public String name; 33 | public String fieldName; 34 | public Class fieldClass; 35 | public String value; 36 | public Object actualValue; 37 | public String description; 38 | public Level level; 39 | } 40 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/FloatPrimitiveTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | import com.cloudhopper.commons.xbean.TypeConverter; 25 | 26 | /** 27 | * Converts a String to a float. 28 | * 29 | * @author joelauer 30 | */ 31 | public class FloatPrimitiveTypeConverter implements TypeConverter { 32 | 33 | @Override 34 | public Object convert(String value) throws ConversionException { 35 | try { 36 | return Float.parseFloat(value); 37 | } catch (NumberFormatException e) { 38 | throw new ConversionException(e.getMessage()); 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /ch-jetty/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | true 25 | System.err 26 | 27 | %-23d [%thread] %-5level %logger{32} - %m%n 28 | 29 | 30 | DEBUG 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/servlet/HttpStatusCodeException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp.servlet; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class HttpStatusCodeException extends Exception { 28 | private static final long serialVersionUID = 0L; 29 | 30 | private int statusCode; 31 | 32 | /** 33 | * Constructs an instance of ApiHttpException with the specified detail message. 34 | * @param msg the detail message. 35 | */ 36 | public HttpStatusCodeException(int statusCode, String msg) { 37 | super(msg); 38 | this.statusCode = statusCode; 39 | } 40 | 41 | public int getStatusCode() { 42 | return this.statusCode; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/DoublePrimitiveTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | import com.cloudhopper.commons.xbean.TypeConverter; 25 | 26 | /** 27 | * Converts a String to a double. 28 | * 29 | * @author joelauer 30 | */ 31 | public class DoublePrimitiveTypeConverter implements TypeConverter { 32 | 33 | @Override 34 | public Object convert(String value) throws ConversionException { 35 | try { 36 | return Double.parseDouble(value); 37 | } catch (NumberFormatException e) { 38 | throw new ConversionException(e.getMessage()); 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /ch-commons-gsm/README.md: -------------------------------------------------------------------------------- 1 | Cloudhopper by Twitter 2 | ============================ 3 | 4 | cloudhopper-commons-gsm 5 | ----------------------- 6 | 7 | Utility Java classes for working with GSM mobile technologies (usually SMS or MMS). 8 | Here are just some of the utilities: 9 | 10 | - Parsing Data Coding Scheme values or splitting up an SMS 11 | - Splitting an SMS properly for concatenation 12 | - Parsing User Data Headers from byte arrays 13 | 14 | Contributors 15 | ------------ 16 | 17 | Joe Lauer (Twitter: [@jjlauer](http://twitter.com/jjlauer)) 18 | 19 | Installation 20 | ------------ 21 | 22 | Library versions >= 3.0.0 are now published to the Maven Central Repository. 23 | Just add the following dependency to your project maven pom.xml: 24 | 25 | 26 | com.cloudhopper 27 | ch-commons-gsm 28 | [3.0.0,) 29 | 30 | 31 | Demo Code / Tutorials 32 | --------------------- 33 | 34 | There are numerous examples of how to use various parts of this library: 35 | 36 | src/test/java/com/cloudhopper/commons/gsm/demo 37 | 38 | To run some of the samples, there is a Makefile to simplify the syntax required 39 | by Maven: 40 | 41 | make datacoding 42 | 43 | On Windows, you can use `nmake` in place of `make` 44 | 45 | License 46 | ------- 47 | 48 | Copyright (C) 2010-2012 Twitter, Inc. 49 | 50 | This work is licensed under the Apache License, Version 2.0. See LICENSE for details. -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/sample/InternetPerson.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.sample; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 26 | */ 27 | public class InternetPerson extends Person { 28 | 29 | private String email; 30 | 31 | public InternetPerson() { 32 | super(); 33 | } 34 | 35 | public String getEmail() { 36 | return email; 37 | } 38 | 39 | public void setEmail(String emailAddress) { 40 | this.email = emailAddress; 41 | } 42 | 43 | /** only a get, not a set! */ 44 | public String getEmail2() { 45 | return email; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/PropertyNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when a property is not found on a Java object. 25 | * @author joelauer 26 | */ 27 | public class PropertyNotFoundException extends BasePropertyException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | public PropertyNotFoundException(String propertyName, String xmlPath, Class targetClass, String msg) { 31 | this(propertyName, xmlPath, targetClass, msg, null); 32 | } 33 | 34 | public PropertyNotFoundException(String propertyName, String xmlPath, Class targetClass, String msg, Throwable t) { 35 | super(propertyName, xmlPath, targetClass, msg, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/PropertyPermissionException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when access to a property or class is denied. 25 | * @author joelauer 26 | */ 27 | public class PropertyPermissionException extends BasePropertyException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | public PropertyPermissionException(String propertyName, String xmlPath, Class targetClass, String msg) { 31 | this(propertyName, xmlPath, null, msg, null); 32 | } 33 | 34 | public PropertyPermissionException(String propertyName, String xmlPath, Class targetClass, String msg, Throwable t) { 35 | super(propertyName, xmlPath, targetClass, msg, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/PropertyConversionException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when a property fails during conversion to a Java object. 25 | * @author joelauer 26 | */ 27 | public class PropertyConversionException extends BasePropertyException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | public PropertyConversionException(String propertyName, String xmlPath, Class targetClass, String msg) { 31 | this(propertyName, xmlPath, null, msg, null); 32 | } 33 | 34 | public PropertyConversionException(String propertyName, String xmlPath, Class targetClass, String msg, Throwable t) { 35 | super(propertyName, xmlPath, targetClass, msg, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/XmlBeanProperty.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | /** 29 | * 30 | * 31 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 32 | */ 33 | @Retention(RetentionPolicy.RUNTIME) 34 | @Target(ElementType.FIELD) 35 | public @interface XmlBeanProperty { 36 | /** Name of element for the value of a collection/map */ 37 | String value() default ""; 38 | /** Name of element for the key of a map value */ 39 | String key() default ""; 40 | } 41 | -------------------------------------------------------------------------------- /ch-jetty/src/main/java/com/cloudhopper/jetty/JettyExecutorThreadPool.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.jetty; 2 | 3 | /* 4 | * #%L 5 | * ch-jetty 6 | * %% 7 | * Copyright (C) 2012 - 2015 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.concurrent.ThreadPoolExecutor; 24 | import org.eclipse.jetty.util.thread.ExecutorThreadPool; 25 | 26 | /** 27 | * Jetty ThreadPool exposing the underlying ThreadPoolExecutor. Use with care. 28 | * This class wraps a ThreadPoolExecutor as a ThreadPool. 29 | * @author garth 30 | */ 31 | public class JettyExecutorThreadPool extends ExecutorThreadPool { 32 | private final ThreadPoolExecutor executor; 33 | 34 | public JettyExecutorThreadPool(ThreadPoolExecutor executor) { 35 | super(executor); 36 | this.executor = executor; 37 | } 38 | 39 | public ThreadPoolExecutor getExecutor() { 40 | return this.executor; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/URLTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | import com.cloudhopper.commons.xbean.TypeConverter; 25 | import java.net.MalformedURLException; 26 | import java.net.URL; 27 | 28 | /** 29 | * Converts a String to a URL. 30 | * 31 | * @author joelauer 32 | */ 33 | public class URLTypeConverter implements TypeConverter { 34 | 35 | @Override 36 | public Object convert(String value) throws ConversionException { 37 | try { 38 | return new URL(value); 39 | } catch (MalformedURLException e) { 40 | throw new ConversionException(e.getMessage()); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/SubstitutionException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Root exception for StringUtil where environment variables can be used to 25 | * replace certain properties. 26 | * 27 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 28 | */ 29 | public class SubstitutionException extends Exception { 30 | private static final long serialVersionUID = 1L; 31 | 32 | /** 33 | * Constructs an instance of SubstitutionException with the specified detail message. 34 | * @param msg the detail message. 35 | */ 36 | public SubstitutionException(String msg) { 37 | super(msg); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/PropertyAlreadySetException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when a property was already set in an xml document once before. 25 | * @author joelauer 26 | */ 27 | public class PropertyAlreadySetException extends BasePropertyException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | public PropertyAlreadySetException(String propertyName, String xmlPath, Class targetClass, String msg) { 31 | this(propertyName, xmlPath, null, msg, null); 32 | } 33 | 34 | public PropertyAlreadySetException(String propertyName, String xmlPath, Class targetClass, String msg, Throwable t) { 35 | super(propertyName, xmlPath, targetClass, msg, t); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/PropertyIsEmptyException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown if a property was included in an xml document, but not value was 25 | * assigned to it. 26 | * @author joelauer 27 | */ 28 | public class PropertyIsEmptyException extends BasePropertyException { 29 | private static final long serialVersionUID = 1L; 30 | 31 | public PropertyIsEmptyException(String propertyName, String xmlPath, Class targetClass, String msg) { 32 | this(propertyName, xmlPath, null, msg, null); 33 | } 34 | 35 | public PropertyIsEmptyException(String propertyName, String xmlPath, Class targetClass, String msg, Throwable t) { 36 | super(propertyName, xmlPath, targetClass, msg, t); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ch-commons-charset/Makefile: -------------------------------------------------------------------------------- 1 | charset1: 2 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.CharsetMain" 3 | 4 | charset2: 5 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.Charset2Main" 6 | 7 | charset3: 8 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.Charset3Main" 9 | 10 | charset4: 11 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.Charset4Main" 12 | 13 | charset5: 14 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.Charset5Main" 15 | 16 | charset6: 17 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.Charset6Main" 18 | 19 | benchmark: 20 | mvn test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.BenchmarkMain" 21 | 22 | utf8-benchmark: 23 | mvn -e test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.UTF8BenchmarkMain" 24 | 25 | gsm-benchmark: 26 | mvn -e test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.GSMBenchmarkMain" 27 | 28 | string-reflection: 29 | mvn -e test-compile exec:java -Dexec.classpathScope="test" -Dexec.mainClass="com.cloudhopper.commons.charset.demo.StringReflectionMain" -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/PropertyInvalidTypeException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown if a type was invalid such as a class not found or mismatched types. 25 | * 26 | * @author joelauer 27 | */ 28 | public class PropertyInvalidTypeException extends BasePropertyException { 29 | private static final long serialVersionUID = 1L; 30 | 31 | public PropertyInvalidTypeException(String propertyName, String xmlPath, Class targetClass, String msg) { 32 | this(propertyName, xmlPath, null, msg, null); 33 | } 34 | 35 | public PropertyInvalidTypeException(String propertyName, String xmlPath, Class targetClass, String msg, Throwable t) { 36 | super(propertyName, xmlPath, targetClass, msg, t); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/sample/ServerConfigException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.sample; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 26 | */ 27 | public class ServerConfigException extends Exception { 28 | 29 | /** 30 | * Creates a new instance of ServerConfigException without detail message. 31 | */ 32 | public ServerConfigException() { 33 | } 34 | 35 | 36 | /** 37 | * Constructs an instance of ServerConfigException with the specified detail message. 38 | * @param msg the detail message. 39 | */ 40 | public ServerConfigException(String msg) { 41 | super(msg); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ch-commons-charset/src/test/java/com/cloudhopper/commons/charset/demo/Charset5Main.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.charset.CharsetUtil; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | /** 28 | * 29 | * @author joelauer 30 | */ 31 | public class Charset5Main { 32 | private static final Logger logger = LoggerFactory.getLogger(Charset5Main.class); 33 | 34 | static public void main(String[] args) throws Exception { 35 | String sourceString = "h\u6025\u20ACllo"; 36 | 37 | String targetString = CharsetUtil.normalize(sourceString, CharsetUtil.CHARSET_UTF_8); 38 | 39 | logger.debug("source string: " + sourceString); 40 | logger.debug("target string: " + targetString); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/BufferException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 26 | */ 27 | public class BufferException extends RuntimeException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Creates a new instance of BufferException without detail message. 32 | */ 33 | public BufferException() { 34 | } 35 | 36 | 37 | /** 38 | * Constructs an instance of BufferException with the specified detail message. 39 | * @param msg the detail message. 40 | */ 41 | public BufferException(String msg) { 42 | super(msg); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/PropertyNoAttributesExpectedException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown if attributes are included for an xml element when no attributes 25 | * are expected. 26 | * @author joelauer 27 | */ 28 | public class PropertyNoAttributesExpectedException extends BasePropertyException { 29 | private static final long serialVersionUID = 1L; 30 | 31 | public PropertyNoAttributesExpectedException(String propertyName, String xmlPath, Class targetClass, String msg) { 32 | this(propertyName, xmlPath, null, msg, null); 33 | } 34 | 35 | public PropertyNoAttributesExpectedException(String propertyName, String xmlPath, Class targetClass, String msg, Throwable t) { 36 | super(propertyName, xmlPath, targetClass, msg, t); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ch-sxmp/README: -------------------------------------------------------------------------------- 1 | Cloudhopper, Inc. 2 | http://www.cloudhopper.com/ 3 | SXMP Library 4 | -------------------------------------------------------------------------------- 5 | 6 | Library implementing the SXMP protocol. SXMP is like SMPP, but as readable XML. 7 | 8 | Error Codes: 9 | 10 | 1001 : Only one "XXXX" element supported 11 | 1002 : Account element must contain a username attribute and value 12 | 1003 : Account element must contain a password attribute and value 13 | 1004 : Only one submitRequest element supported 14 | 1005 : One or more characters in the referenceId value are not allowed 15 | 1006 : The operatorId must be greater than 0 16 | 1007 : Mismatch between operation type and embedded request element 17 | 1008 : Unsupported child element "XXXXX" found 18 | 1009 : Element "XXXXX" must contain a value 19 | 1010 : Unable to convert "XXXX" to a number 20 | 1011 : An address element must contain a type attribute value 21 | 22 | To do: 23 | 24 | * Support for binary messages 25 | * Provide a better common implementation of a "sender" framework similar to 26 | how a servlet implementation was provided. 27 | * Provide a simulator servlet that can have various options turned on/off at 28 | runtime to mimic error scenarios. 29 | * Some additional unit tests -- perhaps a test suite for customer implementations 30 | of our protocol? 31 | * Add an "enquire_link" implementation. Calling it a PingRequest or KeepAliveRequest 32 | is probably what I'm going after. 33 | * Load tester/simulator app? Perhaps combine together with various tools above 34 | into the same package. 35 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/TextEncoding.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Enumeration of all text encodings supported by the SXMP protocol. 25 | * 26 | * @author joelauer 27 | */ 28 | public enum TextEncoding { 29 | 30 | ISO_8859_1 ("ISO-8859-1"), 31 | UTF_8 ("UTF-8"); 32 | 33 | private final String charset; 34 | 35 | TextEncoding(final String charset) { 36 | this.charset = charset; 37 | } 38 | 39 | public String getCharset() { 40 | return this.charset; 41 | } 42 | 43 | public static TextEncoding valueOfCharset(final String charset) { 44 | for (TextEncoding e : TextEncoding.values()) { 45 | if (e.charset.equalsIgnoreCase(charset)) { 46 | return e; 47 | } 48 | } 49 | return null; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/BufferSizeException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 26 | */ 27 | public class BufferSizeException extends BufferException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Creates a new instance of BufferSizeException without detail message. 32 | */ 33 | public BufferSizeException() { 34 | super(); 35 | } 36 | 37 | 38 | /** 39 | * Constructs an instance of BufferSizeException with the specified detail message. 40 | * @param msg the detail message. 41 | */ 42 | public BufferSizeException(String msg) { 43 | super(msg); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/windowing/WindowListener.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.windowing; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Interface for listening to events triggered by a window. 25 | * 26 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 27 | */ 28 | public interface WindowListener { 29 | 30 | /** 31 | * Called when a future has been automatically expired by a window in its 32 | * internal monitoring task. Since the thread that will call this method 33 | * is potentially shared by any window in the JVM, it's best to handle this 34 | * event as quickly as possible. 35 | * @param future The future that expired based on its ExpireTimestamp 36 | */ 37 | public void expired(WindowFuture future); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/windowing/PendingOfferAbortedException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.windowing; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when a caller/thread is waiting for an offer to be accepted, but 25 | * abortPendingOffers() is called by a different thread. Rather than wait for the 26 | * offer to be accepted for the full offerTimeoutMillis, this is an immediate timeout. 27 | * 28 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 29 | */ 30 | public class PendingOfferAbortedException extends OfferTimeoutException { 31 | 32 | public PendingOfferAbortedException(String msg) { 33 | super(msg); 34 | } 35 | 36 | public PendingOfferAbortedException(String msg, Throwable t) { 37 | super(msg, t); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/BooleanPrimitiveTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | import com.cloudhopper.commons.xbean.TypeConverter; 25 | 26 | /** 27 | * Converts a String to a boolean. 28 | * @author joelauer 29 | */ 30 | public class BooleanPrimitiveTypeConverter implements TypeConverter { 31 | 32 | @Override 33 | public Object convert(String value) throws ConversionException { 34 | if (value.equalsIgnoreCase("true")) { 35 | return true; 36 | } else if (value.equalsIgnoreCase("false")) { 37 | return false; 38 | } else { 39 | throw new ConversionException("A boolean value must either be 'true' or 'false' [actual='" + value + "']"); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/BooleanTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | import com.cloudhopper.commons.xbean.TypeConverter; 25 | 26 | /** 27 | * Converts a String to a Boolean. 28 | * @author joelauer 29 | */ 30 | public class BooleanTypeConverter implements TypeConverter { 31 | 32 | @Override 33 | public Object convert(String value) throws ConversionException { 34 | if (value.equalsIgnoreCase("true")) { 35 | return Boolean.TRUE; 36 | } else if (value.equalsIgnoreCase("false")) { 37 | return Boolean.FALSE; 38 | } else { 39 | throw new ConversionException("A boolean value must either be 'true' or 'false' [actual='" + value + "']"); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/BufferIsFullException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 26 | */ 27 | public class BufferIsFullException extends BufferException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Creates a new instance of BufferIsFullException without detail message. 32 | */ 33 | public BufferIsFullException() { 34 | super(); 35 | } 36 | 37 | 38 | /** 39 | * Constructs an instance of BufferIsFullException with the specified detail message. 40 | * @param msg the detail message. 41 | */ 42 | public BufferIsFullException(String msg) { 43 | super(msg); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/Application.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.sxmp.util.ToStringUtil; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | /** 28 | * 29 | * @author joelauer 30 | */ 31 | public class Application { 32 | private static final Logger logger = LoggerFactory.getLogger(Application.class); 33 | 34 | private String name; 35 | 36 | public Application() { 37 | // do nothing 38 | } 39 | 40 | public Application(String name) { 41 | this.name = name; 42 | } 43 | 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | public void setName(String name) { 49 | this.name = name; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return ToStringUtil.nullSafe(this.name); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/BufferIsEmptyException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 26 | */ 27 | public class BufferIsEmptyException extends BufferException { 28 | private static final long serialVersionUID = 1L; 29 | 30 | /** 31 | * Creates a new instance of BufferIsEmptyException without detail message. 32 | */ 33 | public BufferIsEmptyException() { 34 | super(); 35 | } 36 | 37 | 38 | /** 39 | * Constructs an instance of BufferIsEmptyException with the specified detail message. 40 | * @param msg the detail message. 41 | */ 42 | public BufferIsEmptyException(String msg) { 43 | super(msg); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /ch-commons-rfs/src/main/java/com/cloudhopper/commons/rfs/FileSystemException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.rfs; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-rfs 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Root exception for any interactions with a remote filesystem. 25 | * 26 | * @author joelauer 27 | */ 28 | public class FileSystemException extends Exception { 29 | private static final long serialVersionUID = 1L; 30 | 31 | /** 32 | * Constructs an instance of FileSystemException with the specified detail message. 33 | * @param msg the detail message. 34 | */ 35 | public FileSystemException(String msg) { 36 | super(msg); 37 | } 38 | 39 | /** 40 | * Constructs an instance of FileSystemException with the specified detail message. 41 | * @param msg the detail message. 42 | */ 43 | public FileSystemException(String msg, Throwable t) { 44 | super(msg, t); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/PropertyInvocationException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Thrown when the underlying Java object throws an exception while attempting 25 | * to either get or set a property value. 26 | * @author joelauer 27 | */ 28 | public class PropertyInvocationException extends BasePropertyException { 29 | private static final long serialVersionUID = 1L; 30 | 31 | public PropertyInvocationException(String propertyName, String xmlPath, Class targetClass, String msg, String errorMessage) { 32 | this(propertyName, xmlPath, null, msg, errorMessage, null); 33 | } 34 | 35 | public PropertyInvocationException(String propertyName, String xmlPath, Class targetClass, String msg, String errorMessage, Throwable t) { 36 | super(propertyName, xmlPath, targetClass, msg + " [error='" + errorMessage + "']", t); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/SQLConfigurationException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.sql; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-sql 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.sql.SQLException; 24 | 25 | /** 26 | * Thrown if an error occurs while configuring a DataSourceFactory or DataSource. 27 | * 28 | * @author joelauer 29 | */ 30 | public class SQLConfigurationException extends SQLException { 31 | 32 | /** 33 | * Constructs an instance of SQLConfigurationException with the specified detail message. 34 | * @param msg the detail message. 35 | */ 36 | public SQLConfigurationException(String msg) { 37 | super(msg); 38 | } 39 | 40 | /** 41 | * Constructs an instance of SQLConfigurationException with the specified detail message. 42 | * @param msg the detail message. 43 | */ 44 | public SQLConfigurationException(String msg, Throwable t) { 45 | super(msg, t); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # ch-commons-xbean 4 | # %% 5 | # Copyright (C) 2012 Cloudhopper by Twitter 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | log4j.rootLogger=WARN, CONSOLE 21 | 22 | log4j.logger.org.apache.catalina=WARN 23 | log4j.logger.org.apache.jasper=WARN 24 | log4j.logger.org.apache.commons=FATAL 25 | log4j.logger.net.cloudhopper=DEBUG 26 | #log4j.logger.springapp=DEBUG 27 | #log4j.logger.org.springframework=DEBUG 28 | 29 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 30 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 31 | # this pattern does not include the thread name 32 | log4j.appender.CONSOLE.layout.ConversionPattern=%-4r %-5p %C{1} - %m%n 33 | # this pattern includes the thread name 34 | #log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %C{1} - %m%n 35 | 36 | #log4j.appender.LOGFILE=biz.minaret.log4j.DatedFileAppender 37 | #log4j.appender.LOGFILE.Prefix=ch-commons. 38 | #log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout 39 | #log4j.appender.LOGFILE.layout.ConversionPattern=%-23d %p %c - %m%n -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/SQLMissingDependencyException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.sql; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-sql 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.sql.SQLException; 24 | 25 | /** 26 | * Thrown if an error occurs while configuring a DataSourceFactory or DataSource. 27 | * 28 | * @author joelauer 29 | */ 30 | public class SQLMissingDependencyException extends SQLException { 31 | 32 | /** 33 | * Constructs an instance of SQLConfigurationException with the specified detail message. 34 | * @param msg the detail message. 35 | */ 36 | public SQLMissingDependencyException(String msg) { 37 | super(msg); 38 | } 39 | 40 | /** 41 | * Constructs an instance of SQLConfigurationException with the specified detail message. 42 | * @param msg the detail message. 43 | */ 44 | public SQLMissingDependencyException(String msg, Throwable t) { 45 | super(msg, t); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/DataSourceProvider.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.sql; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-sql 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Enumeration of DataSource providers. 25 | * 26 | * @author joelauer 27 | */ 28 | public enum DataSourceProvider { 29 | 30 | /** c3p0 datasource pooling provider */ 31 | C3P0("com.cloudhopper.commons.sql.c3p0.C3P0DataSourceAdapter"), 32 | /** Proxool datasource pooling provider */ 33 | PROXOOL("com.cloudhopper.commons.sql.proxool.ProxoolDataSourceAdapter"), 34 | /** Basic datasource provider, no pooling */ 35 | BASIC("com.cloudhopper.commons.sql.adapter.BasicDataSourceAdapter"); 36 | 37 | private final String adapter; 38 | 39 | DataSourceProvider(final String adapter) { 40 | this.adapter = adapter; 41 | } 42 | 43 | /** 44 | * Gets the adapter for this provider. 45 | */ 46 | public String getAdapter() { 47 | return this.adapter; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/demo/EnvironmentUtilMain.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | // java imports 24 | import com.cloudhopper.commons.util.EnvironmentException; 25 | import com.cloudhopper.commons.util.EnvironmentUtil; 26 | import java.util.*; 27 | 28 | /** 29 | * Demos EnvironmentUtil class. 30 | * 31 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 32 | */ 33 | public class EnvironmentUtilMain { 34 | 35 | public static void main(String[] args) throws EnvironmentException { 36 | Properties systemProperties = EnvironmentUtil.createCommonSystemProperties(); 37 | for (String systemProperty : systemProperties.stringPropertyNames()) { 38 | String value = systemProperties.getProperty(systemProperty); 39 | System.out.println(systemProperty + ": " + value); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/test/java/com/cloudhopper/commons/xbean/type/URLTypeConverterTest.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.xbean.ConversionException; 24 | import com.cloudhopper.commons.xbean.TypeConverter; 25 | import org.apache.log4j.Logger; 26 | import org.junit.Test; 27 | 28 | public class URLTypeConverterTest { 29 | private static final Logger logger = Logger.getLogger(URLTypeConverterTest.class); 30 | 31 | private TypeConverter pc = new URLTypeConverter(); 32 | 33 | @Test 34 | public void validConversions() throws Exception { 35 | pc.convert("http://www.google.com"); 36 | pc.convert("http://www.google.com/yo"); 37 | pc.convert("http://www.google.com:81/yo?id=1"); 38 | } 39 | 40 | @Test(expected=ConversionException.class) 41 | public void invalidURLThrowsException() throws Exception { 42 | pc.convert("www.google.com:81/yo?id=1"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/RandomUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | // third party imports 24 | import org.junit.*; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | /** 29 | * 30 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 31 | */ 32 | public class RandomUtilTest { 33 | 34 | private static final Logger logger = LoggerFactory.getLogger(RandomUtilTest.class); 35 | 36 | @Test 37 | public void generateString() { 38 | // can really only test the length since its a random num 39 | String result = RandomUtil.generateString(2); 40 | Assert.assertEquals(2, result.length()); 41 | 42 | result = RandomUtil.generateString(20); 43 | Assert.assertEquals(20, result.length()); 44 | 45 | result = RandomUtil.generateString(8); 46 | Assert.assertEquals(8, result.length()); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /ch-commons-charset/src/main/java/com/cloudhopper/commons/charset/ISO88591Charset.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * This class encodes and decodes Java Strings to and from the Latin-1/ISO-8859-1 25 | * alphabet. 26 | * 27 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 28 | */ 29 | public class ISO88591Charset extends JavaCharset { 30 | 31 | public ISO88591Charset() { 32 | super("ISO-8859-1"); 33 | } 34 | 35 | @Override 36 | public int estimateEncodeByteLength(CharSequence str0) { 37 | if (str0 == null) { 38 | return 0; 39 | } 40 | // only 8-bit chars 41 | return str0.length(); 42 | } 43 | 44 | @Override 45 | public int estimateDecodeCharLength(byte[] bytes) { 46 | if (bytes == null) { 47 | return 0; 48 | } 49 | // only 8-bit chars 50 | return bytes.length; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/sample/ServerConfig.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.sample; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Sample configuration object for a server. 25 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 26 | */ 27 | public class ServerConfig { 28 | 29 | private String host; 30 | private int port; 31 | 32 | public ServerConfig() { 33 | // do nothing 34 | } 35 | 36 | public int getPort() { 37 | return port; 38 | } 39 | 40 | public void setPort(int value) throws ServerConfigException { 41 | // only non-negative 42 | if (value <= 0) { 43 | throw new ServerConfigException("Port must be > 0"); 44 | } 45 | this.port = value; 46 | } 47 | 48 | public String getHost() { 49 | return this.host; 50 | } 51 | 52 | public void setHost(String value) { 53 | this.host = value; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ch-commons-charset/src/main/java/com/cloudhopper/commons/charset/ISO885915Charset.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * This class encodes and decodes Java Strings to and from the Latin-9/ISO-8859-15 25 | * alphabet. 26 | * 27 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 28 | */ 29 | public class ISO885915Charset extends JavaCharset { 30 | 31 | public ISO885915Charset() { 32 | super("ISO-8859-15"); 33 | } 34 | 35 | @Override 36 | public int estimateEncodeByteLength(CharSequence str0) { 37 | if (str0 == null) { 38 | return 0; 39 | } 40 | // only 8-bit chars 41 | return str0.length(); 42 | } 43 | 44 | @Override 45 | public int estimateDecodeCharLength(byte[] bytes) { 46 | if (bytes == null) { 47 | return 0; 48 | } 49 | // only 8-bit chars 50 | return bytes.length; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/filefilter/CompositeFileFilter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.filefilter; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.File; 24 | import java.io.FileFilter; 25 | 26 | /** 27 | * Filters a file based on a composition of several other filters. 28 | * 29 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 30 | */ 31 | public class CompositeFileFilter implements FileFilter { 32 | 33 | private FileFilter[] filters; 34 | 35 | public CompositeFileFilter(FileFilter[] filters) { 36 | this.filters = filters; 37 | } 38 | 39 | @Override 40 | public boolean accept(File file) { 41 | // loop thru every filter 42 | for (FileFilter filter : filters) { 43 | if (!filter.accept(file)) { 44 | return false; 45 | } 46 | } 47 | // if we get here then everything matched! 48 | return true; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /ch-commons-gsm/src/main/java/com/cloudhopper/commons/gsm/Ton.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.gsm; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-gsm 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Enum class that represents a Type of Number (TON) in the GSM world. 25 | * 26 | * @author joelauer 27 | */ 28 | public enum Ton { 29 | 30 | UNKNOWN (GsmConstants.TON_UNKNOWN), 31 | INTERNATIONAL (GsmConstants.TON_INTERNATIONAL), 32 | NATIONAL (GsmConstants.TON_NATIONAL), 33 | NETWORK (GsmConstants.TON_NETWORK), 34 | SUBSCRIBER (GsmConstants.TON_SUBSCRIBER), 35 | ALPHANUMERIC (GsmConstants.TON_ALPHANUMERIC), 36 | ABBREVIATED (GsmConstants.TON_ABBREVIATED); 37 | 38 | private final int ton; 39 | 40 | Ton(final int ton) { 41 | this.ton = ton; 42 | } 43 | 44 | public int toInt() { 45 | return this.ton; 46 | } 47 | 48 | public static Ton fromInt(final int ton) { 49 | for (Ton e : Ton.values()) { 50 | if (e.ton == ton) { 51 | return e; 52 | } 53 | } 54 | return null; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/DeliveryStatus.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * 28 | * @author joelauer 29 | */ 30 | public class DeliveryStatus { 31 | private static final Logger logger = LoggerFactory.getLogger(DeliveryStatus.class); 32 | 33 | private final Integer code; 34 | private final String message; 35 | 36 | public DeliveryStatus(Integer code, String message) { 37 | this.code = code; 38 | this.message = message; 39 | } 40 | 41 | public Integer getCode() { 42 | return this.code; 43 | } 44 | 45 | public String getMessage() { 46 | return this.message; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return new StringBuilder(20) 52 | .append("[") 53 | .append(code) 54 | .append(", ") 55 | .append(message) 56 | .append("]") 57 | .toString(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ch-commons-gsm/src/main/java/com/cloudhopper/commons/gsm/Npi.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.gsm; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-gsm 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Enum class that represents a Numbering Plan Indicator (NPI) in the GSM world. 25 | * 26 | * @author joelauer 27 | */ 28 | public enum Npi { 29 | 30 | UNKNOWN (GsmConstants.NPI_UNKNOWN), 31 | ISDN (GsmConstants.NPI_ISDN), 32 | DATA (GsmConstants.NPI_DATA), 33 | TELEX (GsmConstants.NPI_TELEX), 34 | SERVICE (GsmConstants.NPI_SERVICE), 35 | NATIONAL (GsmConstants.NPI_NATIONAL), 36 | PRIVATE (GsmConstants.NPI_PRIVATE), 37 | ERMES (GsmConstants.NPI_ERMES); 38 | 39 | private final int npi; 40 | 41 | Npi(final int npi) { 42 | this.npi = npi; 43 | } 44 | 45 | public int toInt() { 46 | return this.npi; 47 | } 48 | 49 | public static Npi fromInt(final int npi) { 50 | for (Npi e : Npi.values()) { 51 | if (e.npi == npi) { 52 | return e; 53 | } 54 | } 55 | return null; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/annotation/MetaField.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.annotation; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | /** 29 | * Annotation for including extra meta data about a field inside a class. Useful 30 | * for tagging fields inside a class with a name and description to display. 31 | * Use in conjunction with MetaFieldUtil class. 32 | * 33 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 34 | */ 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Target(ElementType.FIELD) 37 | public @interface MetaField { 38 | /** Name of field */ 39 | String name() default ""; 40 | /** Description of field */ 41 | String description() default ""; 42 | /** Level of field (matches what Log4J uses by name */ 43 | Level level() default Level.INFO; 44 | } 45 | -------------------------------------------------------------------------------- /ch-commons-charset/src/test/java/com/cloudhopper/commons/charset/demo/Charset4Main.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.charset.Charset; 24 | import com.cloudhopper.commons.charset.CharsetUtil; 25 | import com.cloudhopper.commons.util.HexUtil; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | /** 30 | * 31 | * @author joelauer 32 | */ 33 | public class Charset4Main { 34 | private static final Logger logger = LoggerFactory.getLogger(Charset4Main.class); 35 | 36 | static public void main(String[] args) throws Exception { 37 | byte[] bytes = HexUtil.toByteArray("E0A495E0A49AE0A4BE"); 38 | 39 | Charset charset = CharsetUtil.map(CharsetUtil.NAME_UTF_8); 40 | 41 | String decoded = CharsetUtil.decode(bytes, charset); 42 | 43 | byte[] hexDecoded = decoded.getBytes("ISO-10646-UCS-2"); 44 | 45 | logger.info("decoded: " + decoded); 46 | logger.info("decodedAsHex: " + HexUtil.toHexString(hexDecoded)); 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /ch-commons-gsm/src/test/java/com/cloudhopper/commons/gsm/demo/DataCodingMain.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.gsm.demo; 2 | 3 | import com.cloudhopper.commons.gsm.DataCoding; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | /* 8 | * #%L 9 | * ch-commons-gsm 10 | * %% 11 | * Copyright (C) 2012 Cloudhopper by Twitter 12 | * %% 13 | * Licensed under the Apache License, Version 2.0 (the "License"); 14 | * you may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * #L% 25 | */ 26 | 27 | /** 28 | * 29 | * @author joelauer 30 | */ 31 | public class DataCodingMain { 32 | private static final Logger logger = LoggerFactory.getLogger(DataCodingMain.class); 33 | 34 | static public void main(String[] args) throws Exception { 35 | // common DCSs I've seen: -15, 17, 11 36 | // -15 = 0xF1 37 | // 16 = 0x10 38 | // 17 = 0x11 39 | DataCoding dcs = DataCoding.parse((byte)0x11); 40 | 41 | // various settings that can be set purely from a dcs byte value 42 | logger.info("char encoding: " + dcs.getCharacterEncoding()); 43 | logger.info("encoding group: " + dcs.getCodingGroup()); 44 | logger.info("message class: " + dcs.getMessageClass()); 45 | logger.info("is compressed: " + dcs.isCompressed()); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /ch-commons-charset/src/main/java/com/cloudhopper/commons/charset/UCS2Charset.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Charset for UCS2 (ISO-10646-UCS-2 in Java). 25 | * 26 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 27 | */ 28 | public class UCS2Charset extends JavaCharset { 29 | 30 | public UCS2Charset() { 31 | super("ISO-10646-UCS-2"); 32 | } 33 | 34 | @Override 35 | public int estimateEncodeByteLength(CharSequence str0) { 36 | if (str0 == null) { 37 | return 0; 38 | } 39 | // let's double the estimate 40 | return str0.length() * 2; 41 | } 42 | 43 | @Override 44 | public int estimateDecodeCharLength(byte[] bytes) { 45 | if (bytes == null) { 46 | return 0; 47 | } 48 | if (bytes.length % 2 == 0) { 49 | return bytes.length / 2; 50 | } else { 51 | return (bytes.length / 2) + 1; 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/EnvironmentException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * Exception represents a an error while creating environment properties. 27 | * 28 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 29 | */ 30 | public class EnvironmentException extends IOException { 31 | private static final long serialVersionUID = 1L; 32 | 33 | /** 34 | * Constructs an instance of FileAlreadyExistsException with the specified detail message. 35 | * @param msg the detail message. 36 | */ 37 | public EnvironmentException(String msg) { 38 | super(msg); 39 | } 40 | 41 | /** 42 | * Constructs an instance of FileAlreadyExistsException with the specified detail message. 43 | * @param msg the detail message. 44 | */ 45 | public EnvironmentException(String msg, Throwable t) { 46 | super(msg, t); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ch-commons-charset/src/test/java/com/cloudhopper/commons/charset/demo/Charset6Main.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.charset.CharsetUtil; 24 | import com.cloudhopper.commons.util.HexUtil; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | /** 29 | * 30 | * @author joelauer 31 | */ 32 | public class Charset6Main { 33 | private static final Logger logger = LoggerFactory.getLogger(Charset6Main.class); 34 | 35 | static public void main(String[] args) throws Exception { 36 | byte[] vmpbytes = HexUtil.toByteArray("c3a2c282c2ac"); 37 | 38 | // i suspect vmp is double utf-8 encoding this 39 | String decoded1 = CharsetUtil.decode(vmpbytes, CharsetUtil.CHARSET_UTF_8); 40 | 41 | // now get raw bytes 42 | logger.info("decode #1 length: " + decoded1.length()); 43 | 44 | byte[] nextbytes = decoded1.getBytes("ISO-8859-1"); 45 | logger.info("decode #1 bytes: " + HexUtil.toHexString(nextbytes)); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/time/DateTimeYear.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.time; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.joda.time.DateTime; 24 | 25 | /** 26 | * 27 | * 28 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 29 | */ 30 | public class DateTimeYear extends DateTimePeriod { 31 | 32 | protected DateTimeYear(DateTime start, DateTime end) { 33 | super(start, end, DateTimeDuration.YEAR, "yyyy", "yyyy", "yyyy", "yyyy"); 34 | } 35 | 36 | @Override 37 | public DateTimePeriod getNext() { 38 | DateTime next = getStart().plusYears(1); 39 | return DateTimePeriod.createYear(next); 40 | } 41 | 42 | @Override 43 | public DateTimePeriod getPrevious() { 44 | DateTime previous = getStart().minusYears(1); 45 | return DateTimePeriod.createYear(previous); 46 | } 47 | 48 | @Override 49 | public DateTimeDuration getDefaultSubDuration() { 50 | return DateTimeDuration.MONTH; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/time/DateTimeDay.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.time; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.joda.time.DateTime; 24 | 25 | /** 26 | * 27 | * 28 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 29 | */ 30 | public class DateTimeDay extends DateTimePeriod { 31 | 32 | protected DateTimeDay(DateTime start, DateTime end) { 33 | super(start, end, DateTimeDuration.DAY, "yyyy-MM-dd", "MMMM d, yyyy", "yyyy-MM-dd", "dd"); 34 | } 35 | 36 | @Override 37 | public DateTimePeriod getNext() { 38 | DateTime next = getStart().plusDays(1); 39 | return DateTimePeriod.createDay(next); 40 | } 41 | 42 | @Override 43 | public DateTimePeriod getPrevious() { 44 | DateTime previous = getStart().minusDays(1); 45 | return DateTimePeriod.createDay(previous); 46 | } 47 | 48 | @Override 49 | public DateTimeDuration getDefaultSubDuration() { 50 | return DateTimeDuration.HOUR; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/demo/URLParserMain.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.util.URL; 24 | import com.cloudhopper.commons.util.URLParser; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | /** 29 | * 30 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 31 | */ 32 | public class URLParserMain { 33 | private static final Logger logger = LoggerFactory.getLogger(URLParserMain.class); 34 | 35 | public static void main(String[] args) throws Exception { 36 | URL url0 = URLParser.parse("http://www.google.com/"); 37 | 38 | URL url1 = URLParser.parse("http://www.google.com?id=1"); 39 | 40 | URL url2 = URLParser.parse("http:///"); 41 | 42 | URL url3 = URLParser.parse("http://www.google.com"); 43 | 44 | URL url4 = URLParser.parse("http://www.google.com:80"); 45 | 46 | URL url5 = URLParser.parse("http://root@www.google.com/"); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/FileAlreadyExistsException.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.IOException; 24 | 25 | /** 26 | * Exception represents a file already exists and cannot be overwritten. 27 | * 28 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 29 | */ 30 | public class FileAlreadyExistsException extends IOException { 31 | private static final long serialVersionUID = 1L; 32 | 33 | /** 34 | * Constructs an instance of FileAlreadyExistsException with the specified detail message. 35 | * @param msg the detail message. 36 | */ 37 | public FileAlreadyExistsException(String msg) { 38 | super(msg); 39 | } 40 | 41 | /** 42 | * Constructs an instance of FileAlreadyExistsException with the specified detail message. 43 | * @param msg the detail message. 44 | */ 45 | public FileAlreadyExistsException(String msg, Throwable t) { 46 | super(msg, t); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/time/DateTimeMonth.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.time; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.joda.time.DateTime; 24 | 25 | /** 26 | * 27 | * 28 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 29 | */ 30 | public class DateTimeMonth extends DateTimePeriod { 31 | 32 | protected DateTimeMonth(DateTime start, DateTime end) { 33 | super(start, end, DateTimeDuration.MONTH, "yyyy-MM", "MMMM yyyy", "yyyy-MM", "MM"); 34 | } 35 | 36 | @Override 37 | public DateTimePeriod getNext() { 38 | DateTime next = getStart().plusMonths(1); 39 | return DateTimePeriod.createMonth(next); 40 | } 41 | 42 | @Override 43 | public DateTimePeriod getPrevious() { 44 | DateTime previous = getStart().minusMonths(1); 45 | return DateTimePeriod.createMonth(previous); 46 | } 47 | 48 | @Override 49 | public DateTimeDuration getDefaultSubDuration() { 50 | return DateTimeDuration.DAY; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/time/DateTimeHour.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.time; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.joda.time.DateTime; 24 | 25 | /** 26 | * 27 | * 28 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 29 | */ 30 | public class DateTimeHour extends DateTimePeriod { 31 | 32 | protected DateTimeHour(DateTime start, DateTime end) { 33 | super(start, end, DateTimeDuration.HOUR, "yyyy-MM-dd-HH", "MMMM d, yyyy HH:00", "HH:00", "HH"); 34 | } 35 | 36 | @Override 37 | public DateTimePeriod getNext() { 38 | DateTime next = getStart().plusHours(1); 39 | return DateTimePeriod.createHour(next); 40 | } 41 | 42 | @Override 43 | public DateTimePeriod getPrevious() { 44 | DateTime previous = getStart().minusHours(1); 45 | return DateTimePeriod.createHour(previous); 46 | } 47 | 48 | @Override 49 | public DateTimeDuration getDefaultSubDuration() { 50 | return DateTimeDuration.FIVE_MINUTES; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ch-httpclient-util/src/main/java/com/cloudhopper/httpclient/util/DoNotVerifySSLCertificateTrustManager.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.httpclient.util; 2 | 3 | /* 4 | * #%L 5 | * ch-httpclient-util 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.security.cert.CertificateException; 24 | import java.security.cert.X509Certificate; 25 | import javax.net.ssl.X509TrustManager; 26 | 27 | /** 28 | * TrustManager that will trust any SSL certificate. This implementation will 29 | * not verify any attributes of the SSL certificate. This was based on a sample 30 | * provided on the Apache website. 31 | * 32 | * @author joelauer 33 | */ 34 | public class DoNotVerifySSLCertificateTrustManager implements X509TrustManager { 35 | 36 | public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { 37 | // do not verify 38 | } 39 | 40 | public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { 41 | // do not verify 42 | } 43 | 44 | public X509Certificate[] getAcceptedIssuers() { 45 | // do not verify by returning null 46 | return null; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/Account.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * 28 | * @author joelauer 29 | */ 30 | public class Account { 31 | private static final Logger logger = LoggerFactory.getLogger(Account.class); 32 | 33 | private String username; 34 | private String password; 35 | 36 | public Account() { 37 | // do nothing 38 | } 39 | 40 | public Account(String username, String password) { 41 | this.username = username; 42 | this.password = password; 43 | } 44 | 45 | public void setUsername(String value) { 46 | this.username = value; 47 | } 48 | 49 | public String getUsername() { 50 | return this.username; 51 | } 52 | 53 | public void setPassword(String value) { 54 | this.password = value; 55 | } 56 | 57 | public String getPassword() { 58 | return this.password; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return this.username; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/codec/URLEncoderOutputStream.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.codec; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.IOException; 24 | import java.io.OutputStream; 25 | import java.nio.ByteBuffer; 26 | 27 | /** 28 | *

Similar to {@link URLEncoder}, but designed to work with byte and byte array inputs.

29 | * @author Mark A. Ziesemer 30 | * <www.ziesemer.com> 31 | */ 32 | public class URLEncoderOutputStream extends OutputStream{ 33 | 34 | protected final Appendable out; 35 | protected final ByteBuffer singleByteBuffer = ByteBuffer.allocate(1); 36 | 37 | /** 38 | * Encodes to the specified {@link Appendable}. 39 | */ 40 | public URLEncoderOutputStream(Appendable out){ 41 | this.out = out; 42 | } 43 | 44 | @Override 45 | public void write(int b) throws IOException{ 46 | singleByteBuffer.put(0, (byte)b); 47 | URLCodec.encode(singleByteBuffer, out); 48 | } 49 | 50 | @Override 51 | public void write(byte[] b, int off, int len) throws IOException{ 52 | URLCodec.encode(ByteBuffer.wrap(b, off, len), out); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/adapter/BasicManagedDataSource.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.sql.adapter; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-sql 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.sql.DataSourceConfiguration; 24 | import com.cloudhopper.commons.sql.ManagedDataSource; 25 | import javax.sql.DataSource; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | /** 30 | * A basic implementation of a "Managed" DataSource. 31 | * 32 | * @author joelauer 33 | */ 34 | public class BasicManagedDataSource extends ManagedDataSource { 35 | 36 | private static final Logger logger = LoggerFactory.getLogger(BasicManagedDataSource.class); 37 | 38 | public BasicManagedDataSource(DataSourceAdapter adapter, DataSourceConfiguration config, DataSource ds) { 39 | super(adapter, config, ds); 40 | } 41 | 42 | /** Not supported by default */ 43 | public Integer getIdleConnectionCount() { 44 | return null; 45 | } 46 | 47 | public Integer getConnectionCount() { 48 | return null; 49 | } 50 | 51 | public Integer getBusyConnectionCount() { 52 | return null; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.cloudhopper 5 | ch-commons 6 | pom 7 | 1.1 8 | ch-commons 9 | Parent Maven POM for open source cloudhopper-commons projects 10 | https://github.com/twitter/cloudhopper-commons 11 | 12 | 13 | https://github.com/twitter/cloudhopper-commons 14 | scm:git:git://github.com/twitter/cloudhopper-commons.git 15 | scm:git:git@github.com:twitter/cloudhopper-commons.git 16 | master 17 | 18 | 19 | 20 | com.cloudhopper 21 | ch-maven-parent-oss 22 | ch-maven-parent-oss 23 | 1.8-SNAPSHOT 24 | 25 | 26 | 27 | ch-commons-util 28 | ch-commons-charset 29 | ch-commons-gsm 30 | ch-commons-sql 31 | ch-commons-rfs 32 | ch-commons-locale 33 | ch-commons-ssl 34 | ch-commons-io 35 | ch-commons-xbean 36 | ch-httpclient-util 37 | ch-jetty 38 | ch-sxmp 39 | 40 | 41 | 42 | 2014 43 | 4.2.6 44 | 4.2.5 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/time/DateTimeFiveMinutes.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.time; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.joda.time.DateTime; 24 | 25 | /** 26 | * 27 | * 28 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 29 | */ 30 | public class DateTimeFiveMinutes extends DateTimePeriod { 31 | 32 | protected DateTimeFiveMinutes(DateTime start, DateTime end) { 33 | super(start, end, DateTimeDuration.FIVE_MINUTES, "yyyy-MM-dd-HH-mm", "MMMM d, yyyy HH:mm", "HH:mm", "mm"); 34 | } 35 | 36 | @Override 37 | public DateTimePeriod getNext() { 38 | DateTime next = getStart().plusMinutes(5); 39 | return DateTimePeriod.createFiveMinutes(next); 40 | } 41 | 42 | @Override 43 | public DateTimePeriod getPrevious() { 44 | DateTime previous = getStart().minusMinutes(5); 45 | return DateTimePeriod.createFiveMinutes(previous); 46 | } 47 | 48 | @Override 49 | public DateTimeDuration getDefaultSubDuration() { 50 | return DateTimeDuration.MINUTE; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/sample/Person.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util.sample; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 26 | */ 27 | public class Person { 28 | 29 | private int id; 30 | private String firstName; 31 | private String lastName; 32 | private String extraInfo; 33 | 34 | public Person() { 35 | this.id = -1; 36 | } 37 | 38 | public int getId() { 39 | return id; 40 | } 41 | 42 | public void setId(int id) { 43 | this.id = id; 44 | } 45 | 46 | public String getFirstName() { 47 | return this.firstName; 48 | } 49 | 50 | public void setFirstName(String firstName) { 51 | this.firstName = firstName; 52 | } 53 | 54 | public String getLastName() { 55 | return this.lastName; 56 | } 57 | 58 | public void setLastName(String lastName) { 59 | this.lastName = lastName; 60 | } 61 | 62 | protected String getLastName2() { 63 | return this.lastName; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/ManagedDataSourceMBean.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.sql; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-sql 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Defines the MBean properties and methods exposed for a ManagedDataSource. 25 | * 26 | * @author joelauer 27 | */ 28 | public interface ManagedDataSourceMBean { 29 | 30 | // Configuration Attributes 31 | 32 | public String getName(); 33 | public String getUrl(); 34 | public String getDriver(); 35 | public String getDatabaseVendor(); 36 | public String getProvider(); 37 | public String getUsername(); 38 | public String getValidationQuery(); 39 | 40 | public Integer getMinPoolSize(); 41 | public Integer getMaxPoolSize(); 42 | public Long getActiveConnectionTimeout(); 43 | public Long getIdleConnectionTimeout(); 44 | public Long getValidateIdleConnectionTimeout(); 45 | public Boolean getValidateOnCheckin(); 46 | public Boolean getValidateOnCheckout(); 47 | 48 | // Monitoring Attributes 49 | 50 | public Integer getConnectionCount(); 51 | public Integer getIdleConnectionCount(); 52 | public Integer getBusyConnectionCount(); 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /ch-commons-charset/src/test/java/com/cloudhopper/commons/charset/demo/PrintGSMMain.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.charset.GSMCharset; 24 | import com.cloudhopper.commons.util.HexUtil; 25 | 26 | /** 27 | * 28 | * @author joelauer 29 | */ 30 | public class PrintGSMMain { 31 | 32 | static public void main(String[] args) throws Exception { 33 | // utility class for converting CHAR_TABLE and EXT_CHAR_TABLEs into 34 | // switch statements to be used in several methods 35 | printTable(GSMCharset.CHAR_TABLE); 36 | printTable(GSMCharset.EXT_CHAR_TABLE); 37 | } 38 | 39 | static public void printTable(char[] t) { 40 | for (int i = 0; i < t.length; i++) { 41 | char c = t[i]; 42 | if (c > 0) { 43 | if ((c >= ' ' && c <= '_') || (c >= 'a' && c <= '~')) { 44 | // do not print out this! 45 | } else { 46 | System.out.println("case '\\u" + HexUtil.toHexString((short)c) + "':" + "\t// " + c); 47 | } 48 | } 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /ch-jetty/src/test/java/com/cloudhopper/jetty/demo/HelloServlet.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.jetty.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-jetty 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.IOException; 24 | import javax.servlet.ServletException; 25 | import javax.servlet.http.HttpServlet; 26 | import javax.servlet.http.HttpServletRequest; 27 | import javax.servlet.http.HttpServletResponse; 28 | 29 | /** 30 | * 31 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 32 | */ 33 | public class HelloServlet extends HttpServlet { 34 | 35 | private String greeting = "Hello World"; 36 | 37 | public HelloServlet() { 38 | } 39 | 40 | public HelloServlet(String greeting) { 41 | this.greeting = greeting; 42 | } 43 | 44 | @Override 45 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 46 | response.setContentType("text/html"); 47 | response.setStatus(HttpServletResponse.SC_OK); 48 | response.getWriter().println("

" + greeting + "

"); 49 | response.getWriter().println("session=" + request.getSession(true).getId()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ch-sxmp/src/main/java/com/cloudhopper/sxmp/SubmitRequest.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * 25 | * @author joelauer 26 | */ 27 | public class SubmitRequest extends MessageRequest { 28 | 29 | private Boolean deliveryReport; 30 | 31 | public SubmitRequest() { 32 | super(Operation.Type.SUBMIT); 33 | this.deliveryReport = Boolean.FALSE; 34 | } 35 | 36 | public SubmitRequest(String version) { 37 | super(Operation.Type.SUBMIT); 38 | this.deliveryReport = Boolean.FALSE; 39 | this.version = version; 40 | } 41 | 42 | public SubmitResponse createResponse() throws SxmpErrorException { 43 | SubmitResponse submitResp = new SubmitResponse(); 44 | submitResp.setReferenceId(this.getReferenceId()); 45 | return submitResp; 46 | } 47 | 48 | public void setDeliveryReport(Boolean value) { 49 | this.deliveryReport = value; 50 | } 51 | 52 | public Boolean getDeliveryReport() { 53 | return this.deliveryReport; 54 | } 55 | 56 | @Override 57 | public void validate() throws SxmpErrorException { 58 | super.validate(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ch-commons-charset/src/main/java/com/cloudhopper/commons/charset/PackedGSMCharset.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * The PackedGSMCharset class handles the encoding and decoding of the 25 | * GSM default encoding charset, with packing as per GSM 03.38 spec. 26 | * 27 | * The encoding and decoding are based on the mapping at 28 | * http://www.unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT 29 | * 30 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 31 | */ 32 | public class PackedGSMCharset extends GSMCharset { 33 | 34 | @Override 35 | public byte[] encode(CharSequence str0) { 36 | // delete to parent first 37 | byte[] unpacked = super.encode(str0); 38 | // return a "packed" version of it 39 | return GSMBitPacker.pack(unpacked); 40 | } 41 | 42 | @Override 43 | public void decode(byte[] bytes, StringBuilder buffer) { 44 | // unpack the byte array first 45 | byte[] unpacked = GSMBitPacker.unpack(bytes); 46 | // delegate to parent 47 | super.decode(unpacked, buffer); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /ch-commons-util/src/test/java/com/cloudhopper/commons/util/RunningAverageTest.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | // third party imports 24 | import org.junit.*; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | /** 29 | * 30 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 31 | */ 32 | public class RunningAverageTest { 33 | private static final Logger logger = LoggerFactory.getLogger(RunningAverageTest.class); 34 | 35 | @Test 36 | public void runningAverage() { 37 | RunningAverage avg = new RunningAverage(3, 1); 38 | Assert.assertEquals("0.0", avg.toString()); 39 | avg.add(2); 40 | Assert.assertEquals("2.0", avg.toString()); 41 | avg.add(3); 42 | Assert.assertEquals("2.5", avg.toString()); 43 | avg.add(4); 44 | Assert.assertEquals("3.0", avg.toString()); 45 | avg.add(5); 46 | // last value should have kicked out the 2 above 47 | Assert.assertEquals("4.0", avg.toString()); 48 | Assert.assertEquals("4.000", avg.toString(3)); 49 | Assert.assertEquals("4", avg.toString(0)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ch-commons-charset/src/test/java/com/cloudhopper/commons/charset/demo/Charset2Main.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset.demo; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.charset.Charset; 24 | import com.cloudhopper.commons.charset.CharsetUtil; 25 | import com.cloudhopper.commons.util.HexUtil; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | /** 30 | * 31 | * @author joelauer 32 | */ 33 | public class Charset2Main { 34 | private static final Logger logger = LoggerFactory.getLogger(Charset2Main.class); 35 | 36 | static public void main(String[] args) throws Exception { 37 | String str0 = "\u20AC"; 38 | 39 | //Charset charset = new GSMCharset(); 40 | //Charset charset = new PackedGSMCharset(); 41 | //Charset charset = new ISO88591Charset(); 42 | //Charset charset = new UCS2Charset(); 43 | //Charset charset = new UTF8Charset(); 44 | 45 | //Charset charset = CharsetUtil.map(CharsetUtil.NAME_PACKED_GSM); 46 | Charset charset = CharsetUtil.map(CharsetUtil.NAME_ISO_8859_15); 47 | 48 | byte[] encoded = CharsetUtil.encode(str0, charset); 49 | 50 | logger.info("str0: " + str0); 51 | logger.info("encoded: " + HexUtil.toHexString(encoded)); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /ch-sxmp/src/demo/java/com/cloudhopper/sxmp/SenderMain.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.sxmp; 2 | 3 | /* 4 | * #%L 5 | * ch-sxmp 6 | * %% 7 | * Copyright (C) 2012 - 2013 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | /** 27 | * 28 | * @author joelauer 29 | */ 30 | public class SenderMain { 31 | private static final Logger logger = LoggerFactory.getLogger(SenderMain.class); 32 | 33 | static public void main(String[] args) throws Exception { 34 | 35 | String url = "https://sms.twitter.com/receive/cloudhopper"; 36 | 37 | DeliverRequest request = new DeliverRequest(); 38 | request.setAccount(new Account("customer1", "password1")); 39 | request.setTicketId(System.currentTimeMillis()+""); 40 | 41 | MobileAddress sourceAddr = new MobileAddress(MobileAddress.Type.INTERNATIONAL, "+14155551212"); 42 | request.setSourceAddress(sourceAddr); 43 | 44 | MobileAddress destAddr = new MobileAddress(MobileAddress.Type.NETWORK, "40404"); 45 | request.setDestinationAddress(destAddr); 46 | 47 | request.setOperatorId(23); 48 | 49 | request.setText("Hello 2"); 50 | 51 | logger.debug("Request: " + request); 52 | 53 | DeliverResponse response = SxmpSender.deliver(url, request, false); 54 | 55 | logger.debug("Response: " + response); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ch-commons-charset/src/test/java/com/cloudhopper/commons/charset/UTF8CharsetTest.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | // third party imports 24 | import com.cloudhopper.commons.util.HexUtil; 25 | import org.junit.*; 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | /** 30 | * 31 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 32 | */ 33 | public class UTF8CharsetTest { 34 | private static final Logger logger = LoggerFactory.getLogger(UTF8CharsetTest.class); 35 | 36 | @Test 37 | public void emoticons() throws Exception { 38 | // great site: http://www.rishida.net/tools/conversion/ 39 | // U+1F631 is a very high range example of an emoticon (something more people are using) 40 | // UTF-8 bytes look like this: F09F98B1 41 | // UTF-16 bytes look like this: D83DDE31 42 | // JavaScript escapes: \uD83D\uDE31 43 | byte[] bytes = HexUtil.toByteArray("F09F98B1"); 44 | String str = CharsetUtil.CHARSET_UTF_8.decode(bytes); 45 | //logger.debug(str); 46 | //byte[] utf32 = str.getBytes("UTF-32"); 47 | //logger.debug(HexUtil.toHexString(utf32)); 48 | Assert.assertEquals("\uD83D\uDE31", str); // UTF-16 used with JVM 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/RandomUtil.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | // java imports 24 | import java.util.Random; 25 | 26 | /** 27 | * Utility class for using and generating random object such as strings. Useful 28 | * for generating things like random passwords, verification codes, etc. 29 | * 30 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 31 | */ 32 | public class RandomUtil { 33 | 34 | private static final String chars = "abcdefghijklmonpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 35 | private static Random random = new Random(); 36 | 37 | /** 38 | * Creates a random string using only lowercase ascii letters, uppercase 39 | * ascii letters, and digits. This method internally uses a static instance 40 | * of a Random() object. 41 | * @param length The length of random string to generate 42 | * @return A new random string with a length specified in the length parameter 43 | */ 44 | public static String generateString(int length) { 45 | char[] buf = new char[length]; 46 | for (int i = 0; i < buf.length; i++) { 47 | buf[i] = chars.charAt(random.nextInt(chars.length())); 48 | } 49 | return new String(buf); 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /ch-commons-charset/src/main/java/com/cloudhopper/commons/charset/UTF8Charset.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-charset 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Charset for UTF-8. 25 | * 26 | * @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer) 27 | */ 28 | public class UTF8Charset extends JavaCharset { 29 | 30 | public UTF8Charset() { 31 | super("UTF8"); 32 | } 33 | 34 | @Override 35 | public int estimateEncodeByteLength(CharSequence str0) { 36 | if (str0 == null) { 37 | return 0; 38 | } 39 | // let's double the estimate 40 | return str0.length() * 2; 41 | } 42 | 43 | @Override 44 | public int estimateDecodeCharLength(byte[] bytes) { 45 | if (bytes == null) { 46 | return 0; 47 | } 48 | // best guess would be 8-bit chars 49 | return bytes.length; 50 | } 51 | 52 | /** 53 | * Does not actually calculate a proper UTF-8 length, but rather a Modified 54 | * UTF-8 byte length. It normally matches a real UTF-8 encoding but isn't 55 | * technically completely valid. 56 | * @deprecated 57 | */ 58 | @Deprecated 59 | public static int calculateByteLength(final String s) { 60 | return ModifiedUTF8Charset.calculateByteLength(s); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/BytePrimitiveTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.util.ByteArrayUtil; 24 | import com.cloudhopper.commons.util.HexUtil; 25 | import com.cloudhopper.commons.xbean.ConversionException; 26 | import com.cloudhopper.commons.xbean.TypeConverter; 27 | import com.cloudhopper.commons.xbean.util.NumberRadixResult; 28 | import com.cloudhopper.commons.xbean.util.NumberRadixUtil; 29 | 30 | /** 31 | * Converts a String to a byte. 32 | * @author joelauer 33 | */ 34 | public class BytePrimitiveTypeConverter implements TypeConverter { 35 | 36 | @Override 37 | public Object convert(String value) throws ConversionException { 38 | NumberRadixResult result = NumberRadixUtil.parseNumberRadix(value); 39 | try { 40 | if (result.getRadix() == 16) { 41 | String hex = NumberRadixUtil.normalizeLeadingHexZeroes(result.getNumber(), 2); 42 | byte[] bytes = HexUtil.toByteArray(hex); 43 | return ByteArrayUtil.toByte(bytes); 44 | } else { 45 | return Byte.parseByte(result.getNumber()); 46 | } 47 | } catch (NumberFormatException e) { 48 | throw new ConversionException(e.getMessage()); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /ch-commons-util/src/main/java/com/cloudhopper/commons/util/CountingRejectedExecutionHandler.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.util; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-util 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.concurrent.RejectedExecutionException; 24 | import java.util.concurrent.RejectedExecutionHandler; 25 | import java.util.concurrent.ThreadPoolExecutor; 26 | import java.util.concurrent.atomic.AtomicLong; 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | 30 | /** 31 | * An implementation of a RejectedExecutionHandler that counts the number of 32 | * times it has been called. 33 | * 34 | * @author joelauer 35 | */ 36 | public class CountingRejectedExecutionHandler implements RejectedExecutionHandler { 37 | private static final Logger logger = LoggerFactory.getLogger(CountingRejectedExecutionHandler.class); 38 | 39 | private AtomicLong rejected; 40 | 41 | public CountingRejectedExecutionHandler() { 42 | this.rejected = new AtomicLong(); 43 | } 44 | 45 | public void reset() { 46 | this.rejected.set(0); 47 | } 48 | 49 | public long getRejected() { 50 | return this.rejected.get(); 51 | } 52 | 53 | @Override 54 | public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { 55 | this.rejected.incrementAndGet(); 56 | throw new RejectedExecutionException(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/IntegerPrimitiveTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.util.ByteArrayUtil; 24 | import com.cloudhopper.commons.util.HexUtil; 25 | import com.cloudhopper.commons.xbean.ConversionException; 26 | import com.cloudhopper.commons.xbean.TypeConverter; 27 | import com.cloudhopper.commons.xbean.util.NumberRadixResult; 28 | import com.cloudhopper.commons.xbean.util.NumberRadixUtil; 29 | 30 | /** 31 | * Converts a String to an int. 32 | * @author joelauer 33 | */ 34 | public class IntegerPrimitiveTypeConverter implements TypeConverter { 35 | 36 | @Override 37 | public Object convert(String value) throws ConversionException { 38 | NumberRadixResult result = NumberRadixUtil.parseNumberRadix(value); 39 | try { 40 | if (result.getRadix() == 16) { 41 | String hex = NumberRadixUtil.normalizeLeadingHexZeroes(result.getNumber(), 8); 42 | byte[] bytes = HexUtil.toByteArray(hex); 43 | return ByteArrayUtil.toInt(bytes); 44 | } else { 45 | return Integer.parseInt(result.getNumber()); 46 | } 47 | } catch (NumberFormatException e) { 48 | throw new ConversionException(e.getMessage()); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /ch-commons-xbean/src/main/java/com/cloudhopper/commons/xbean/type/ShortPrimitiveTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.xbean.type; 2 | 3 | /* 4 | * #%L 5 | * ch-commons-xbean 6 | * %% 7 | * Copyright (C) 2012 Cloudhopper by Twitter 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.cloudhopper.commons.util.ByteArrayUtil; 24 | import com.cloudhopper.commons.util.HexUtil; 25 | import com.cloudhopper.commons.xbean.ConversionException; 26 | import com.cloudhopper.commons.xbean.TypeConverter; 27 | import com.cloudhopper.commons.xbean.util.NumberRadixResult; 28 | import com.cloudhopper.commons.xbean.util.NumberRadixUtil; 29 | 30 | /** 31 | * Converts a String to a short. 32 | * @author joelauer 33 | */ 34 | public class ShortPrimitiveTypeConverter implements TypeConverter { 35 | 36 | @Override 37 | public Object convert(String value) throws ConversionException { 38 | NumberRadixResult result = NumberRadixUtil.parseNumberRadix(value); 39 | try { 40 | if (result.getRadix() == 16) { 41 | String hex = NumberRadixUtil.normalizeLeadingHexZeroes(result.getNumber(), 4); 42 | byte[] bytes = HexUtil.toByteArray(hex); 43 | return ByteArrayUtil.toShort(bytes); 44 | } else { 45 | return Short.parseShort(result.getNumber()); 46 | } 47 | } catch (NumberFormatException e) { 48 | throw new ConversionException(e.getMessage()); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /ch-commons-charset/src/main/java/com/cloudhopper/commons/charset/UCS2LECharset.java: -------------------------------------------------------------------------------- 1 | package com.cloudhopper.commons.charset; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.ByteOrder; 5 | 6 | /* 7 | * #%L 8 | * ch-commons-charset 9 | * %% 10 | * Copyright (C) 2012 Cloudhopper by Twitter 11 | * %% 12 | * Licensed under the Apache License, Version 2.0 (the "License"); 13 | * you may not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * #L% 24 | */ 25 | 26 | /** 27 | * Charset for UCS2LE (ISO-10646-UCS-2 in Java converted to Little Endian). 28 | * 29 | * @author David Wilkie 30 | */ 31 | public class UCS2LECharset extends UCS2Charset { 32 | @Override 33 | public byte[] encode(CharSequence str0) { 34 | return getLittleEndianBytes(super.encode(str0)); 35 | } 36 | 37 | @Override 38 | public void decode(byte[] bytes, StringBuilder buffer) { 39 | super.decode(getLittleEndianBytes(bytes), buffer); 40 | } 41 | 42 | @Override 43 | public String decode(byte[] bytes) { 44 | return super.decode(getLittleEndianBytes(bytes)); 45 | } 46 | 47 | private byte[] getLittleEndianBytes(byte [] bytes) { 48 | if (bytes == null) { 49 | return null; 50 | } 51 | ByteBuffer sourceByteBuffer = ByteBuffer.wrap(bytes); 52 | ByteBuffer destByteBuffer = ByteBuffer.allocate(bytes.length); 53 | 54 | destByteBuffer.order(ByteOrder.LITTLE_ENDIAN); 55 | while(sourceByteBuffer.hasRemaining()) { 56 | destByteBuffer.putShort(sourceByteBuffer.getShort()); 57 | } 58 | 59 | return destByteBuffer.array(); 60 | } 61 | } 62 | --------------------------------------------------------------------------------