├── .gitignore ├── .gitmodules ├── .travis.yml ├── LICENSE.txt ├── README.md ├── android_update_sdk.sh ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── ormlite-content-provider-compiler-sample ├── .factorypath ├── AndroidManifest.xml ├── assets │ └── LICENSE.txt ├── build.gradle ├── findbugs-exclude.xml ├── ic_launcher-web.png ├── pom.xml ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── layout │ │ └── activity_main.xml │ ├── menu │ │ └── activity_main.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── com │ └── tojc │ └── ormlite │ └── android │ └── ormlitecontentprovider │ └── compiler │ └── sample │ ├── MainActivity.java │ ├── model │ └── Account.java │ └── provider │ ├── MyProvider.java │ └── SampleHelper.java ├── ormlite-content-provider-compiler ├── assets │ └── LICENSE.txt ├── build.gradle ├── javadoc.xml ├── pom.xml ├── proguard-project.txt ├── project.properties └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── tojc │ │ │ └── ormlite │ │ │ └── android │ │ │ └── compiler │ │ │ └── ContractAnnotationProcessor.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── javax.annotation.processing.Processor │ └── test │ ├── java │ ├── com │ │ └── tojc │ │ │ └── ormlite │ │ │ └── android │ │ │ └── compiler │ │ │ ├── AbstractAnnotationProcessorTest.java │ │ │ ├── ContractAnnotationProcessorTest.java │ │ │ └── sample │ │ │ ├── CombinedPojo1.java │ │ │ ├── CombinedPojo2.java │ │ │ ├── CombinedPojo3.java │ │ │ ├── CombinedPojo4.java │ │ │ ├── CombinedPojo5.java │ │ │ ├── CombinedPojo6.java │ │ │ ├── Pojo.java │ │ │ ├── Pojo2.java │ │ │ ├── Pojo3.java │ │ │ ├── Pojo4.java │ │ │ └── PojoWithFields1.java │ └── dummy.txt │ └── resources │ └── com │ └── tojc │ └── ormlite │ └── android │ └── compiler │ └── sample │ ├── CombinedPojoContract1.javasource │ ├── CombinedPojoContract2.javasource │ ├── CombinedPojoContract3.javasource │ ├── LessSimplePojoContract2.javasource │ ├── Pojo3Contract.javasource │ ├── Pojo4Contract.javasource │ ├── PojoContract.javasource │ └── PojoWithFields1Contract.javasource ├── ormlite-content-provider-library-test ├── .factorypath ├── AndroidManifest.xml ├── assets │ └── LICENSE.txt ├── build.gradle ├── findbugs-exclude.xml ├── ic_launcher-web.png ├── pom.xml ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── layout │ │ └── activity_main.xml │ ├── menu │ │ └── activity_main.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── com │ └── tojc │ └── ormlite │ └── android │ ├── TestOrmLiteSimpleProvider.java │ ├── annotation │ └── info │ │ ├── AnnotationInfoBaseTest.java │ │ ├── ContentMimeTypeVndInfoTest.java │ │ └── ContentUriInfoTest.java │ ├── framework │ ├── ColumnInfoTest.java │ ├── MatcherPatternTest.java │ └── MimeTypeVndTest.java │ └── test │ ├── model │ ├── Account.java │ └── Membership.java │ └── provider │ ├── AccountContract.java │ ├── MembershipContract.java │ ├── SampleHelper.java │ └── UnderTestSampleProvider.java ├── ormlite-content-provider-library ├── AndroidManifest.xml ├── assets │ └── LICENSE.txt ├── build.gradle ├── findbugs-exclude.xml ├── javadoc.xml ├── pom.xml ├── proguard-project.txt ├── project.properties ├── res │ └── values │ │ └── dummy.xml ├── src │ └── com │ │ └── tojc │ │ └── ormlite │ │ └── android │ │ ├── OrmLiteBaseContentProvider.java │ │ ├── OrmLiteDefaultContentProvider.java │ │ ├── OrmLiteSimpleContentProvider.java │ │ ├── annotation │ │ ├── AdditionalAnnotation.java │ │ ├── OrmLiteAnnotationAccessor.java │ │ └── info │ │ │ ├── AnnotationInfoBase.java │ │ │ ├── ContentMimeTypeVndInfo.java │ │ │ ├── ContentUriInfo.java │ │ │ ├── ProjectionMapInfo.java │ │ │ └── SortOrderInfo.java │ │ └── framework │ │ ├── ColumnInfo.java │ │ ├── MatcherController.java │ │ ├── MatcherPattern.java │ │ ├── MimeTypeVnd.java │ │ ├── OperationParameters.java │ │ ├── Parameter.java │ │ ├── TableInfo.java │ │ └── Validity.java └── test │ └── java │ └── dummy.txt ├── ormlite-content-provider-sample ├── .factorypath ├── AndroidManifest.xml ├── assets │ └── LICENSE.txt ├── build.gradle ├── findbugs-exclude.xml ├── ic_launcher-web.png ├── pom.xml ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── layout │ │ └── activity_main.xml │ ├── menu │ │ └── activity_main.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── com │ └── tojc │ └── ormlite │ └── android │ └── ormlitecontentprovider │ └── sample │ ├── MainActivity.java │ ├── model │ └── Account.java │ └── provider │ ├── AccountContract.java │ ├── SampleHelper.java │ └── SampleProvider.java ├── pom.gradle ├── pom.xml ├── settings.gradle ├── style_checks.xml └── wait_for_emulator.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | jarlist.cache 11 | 12 | # checkstyle 13 | .checkstyle 14 | 15 | # generated files 16 | bin/ 17 | gen/ 18 | out/ 19 | apt_generated/ 20 | .apt_generated/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | release.properties 25 | 26 | # Eclipse project files 27 | .classpath 28 | .project 29 | .settings 30 | .settings/ 31 | 32 | # Other 33 | .DS_Store 34 | 35 | # libraries for the Eclipse/Ant build system 36 | */libs/ 37 | 38 | # Proguard folder generated by Eclipse 39 | proguard/ 40 | 41 | # Intellij project files 42 | *.idea/ 43 | *.iml 44 | *.ipr 45 | *.iws 46 | 47 | # Maven project files 48 | target/ 49 | 50 | # Gradle 51 | .gradle 52 | build 53 | 54 | # Maven release files 55 | *.releaseBackup 56 | *.versionsBackup 57 | 58 | # symoblic link to action bar sherlock 59 | library 60 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gradle/commonlibrary"] 2 | path = gradle/commonlibrary 3 | url = git://github.com/jakenjarvis/AndroidBuildGradleCommonLibrary.git 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk7 4 | 5 | branches: 6 | excludes: 7 | - gh-pages 8 | 9 | git: 10 | submodules: false 11 | 12 | env: 13 | matrix: 14 | #- ANDROID_TARGET=android-8 ANDROID_SDKS=android-8,build-tools-17.0.0 ANDROID_BUILD_TOOLS_VERSION=17.0.0 ANDROID_ABI=armeabi 15 | #- ANDROID_TARGET=android-10 ANDROID_SDKS=android-10,build-tools-17.0.0,sysimg-10 ANDROID_BUILD_TOOLS_VERSION=17.0.0 ANDROID_ABI=armeabi 16 | #- ANDROID_TARGET=android-15 ANDROID_SDKS=android-15,build-tools-17.0.0,sysimg-15 ANDROID_BUILD_TOOLS_VERSION=17.0.0 ANDROID_ABI=armeabi-v7a 17 | #- ANDROID_TARGET=android-17 ANDROID_SDKS=android-17,build-tools-17.0.0,sysimg-17 ANDROID_BUILD_TOOLS_VERSION=17.0.0 ANDROID_ABI=armeabi-v7a 18 | #- ANDROID_TARGET=android-18 ANDROID_SDKS=android-18,build-tools-18.1.1,sysimg-18 ANDROID_BUILD_TOOLS_VERSION=18.1.1 ANDROID_ABI=armeabi-v7a 19 | #- ANDROID_TARGET=android-19 ANDROID_SDKS=android-19,build-tools-19.0.0,sysimg-19 ANDROID_BUILD_TOOLS_VERSION=19.0.0 ANDROID_ABI=armeabi-v7a 20 | - ANDROID_TARGET=android-19 ANDROID_SDKS=android-19,build-tools-19.0.3,sysimg-19 ANDROID_BUILD_TOOLS_VERSION=19.0.3 ANDROID_ABI=armeabi-v7a 21 | 22 | before_install: 23 | # git submodules update 24 | - git submodule update --init --recursive 25 | 26 | # travis-lint bug? 27 | # Found an issue with the `language:` key: 28 | # Language must be valid 29 | # http://stackoverflow.com/questions/22581057/travis-lint-why-does-it-complain-about-java-language-field 30 | ## check the travis file 31 | #- gem install travis-lint 32 | #- travis-lint 33 | 34 | # Install gradle 1.11 35 | - wget http://services.gradle.org/distributions/gradle-1.11-all.zip > /dev/null 36 | - echo A | unzip gradle-1.11-all.zip > /dev/null 37 | - export GRADLE_HOME=`pwd`/gradle-1.11 38 | - export PATH=${GRADLE_HOME}/bin/:${PATH} 39 | - gradle -v 40 | 41 | ## Install Maven 3.1.1 for android-maven-plugin 3.8.0 over 42 | #- wget http://www.us.apache.org/dist/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz > /dev/null 43 | #- tar xvf apache-maven-3.1.1-bin.tar.gz > /dev/null 44 | #- export M2_HOME=`pwd`/apache-maven-3.1.1 45 | #- export PATH=${M2_HOME}/bin/:${PATH} 46 | #- mvn --version 47 | 48 | ## MAVEN_OPTS 49 | ##- export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" 50 | 51 | # Install base Android SDK 52 | - sudo apt-get update -qq 53 | #- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch; fi 54 | - if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq -o Dpkg::Options::="--force-confold" --force-yes --yes libgd2-xpm ia32-libs ia32-libs-multiarch > /dev/null ; fi 55 | 56 | #- wget http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz > /dev/null 57 | #- tar xzf android-sdk_r22.0.5-linux.tgz > /dev/null 58 | - wget http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz > /dev/null 59 | - tar xzf android-sdk_r22.6.2-linux.tgz > /dev/null 60 | 61 | - export ANDROID_HOME=`pwd`/android-sdk-linux 62 | - export PATH=${PATH}:${ANDROID_HOME}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/build-tools/$ANDROID_BUILD_TOOLS_VERSION 63 | 64 | # Install required Android components. 65 | - android list sdk --all --extended 66 | 67 | # Install android sdk. 68 | - SDK_FILTERS=platform-tools,extra-android-support,extra-android-m2repository,extra-google-m2repository,$ANDROID_SDKS 69 | - chmod +x ./android_update_sdk.sh 70 | - ./android_update_sdk.sh "--filter ${SDK_FILTERS} --no-ui --force" 71 | 72 | ## PROVISIONAL: changed SDKr22 build-tools path. create symbolic link 73 | #- if [ ! -e ${ANDROID_HOME}/platform-tools/aapt ]; then ln -s ${ANDROID_HOME}/build-tools/$ANDROID_BUILD_TOOLS_VERSION/aapt ${ANDROID_HOME}/platform-tools/aapt; fi 74 | #- if [ ! -e ${ANDROID_HOME}/platform-tools/aidl ]; then ln -s ${ANDROID_HOME}/build-tools/$ANDROID_BUILD_TOOLS_VERSION/aidl ${ANDROID_HOME}/platform-tools/aidl; fi 75 | 76 | # Create and start emulator 77 | - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI 78 | - emulator -avd test -no-skin -no-audio -no-window & 79 | 80 | ## PROVISIONAL: android-maven-plugin 81 | #- git clone git://github.com/jayway/maven-android-plugin.git android-maven-plugin 82 | #- cd android-maven-plugin 83 | #- git checkout 84 | #- mvn clean install -N 85 | #- cd .. 86 | 87 | ## PROVISIONAL: maven-android-sdk-deployer 88 | #- git clone git@github.com:mosabua/maven-android-sdk-deployer.git maven-android-sdk-deployer 89 | #- cd maven-android-sdk-deployer 90 | #- git checkout 91 | #- mvn clean install 92 | #- cd .. 93 | 94 | install: gradle clean build 95 | 96 | before_script: 97 | # Make sure the emulator has started before running tests 98 | - chmod +x ./wait_for_emulator.sh 99 | - ./wait_for_emulator.sh > /dev/null 100 | 101 | #script: mvn install -Pintegration-tests -Dandroid.device=test 102 | script: gradle check test connectedAndroidTest 103 | 104 | -------------------------------------------------------------------------------- /android_update_sdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is part of the Android-OrmLiteContentProvider package. 3 | # 4 | # Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | # Jaken Jarvis (jaken.jarvis@gmail.com) 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 | # 19 | # The author may be contacted via 20 | # https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | 22 | PARAM=$* 23 | 24 | if ! type expect >/dev/null 2>&1; then 25 | echo "Install expect" 26 | sudo apt-get install expect -y -qq 27 | expect -v 28 | fi 29 | 30 | expect - </dev/null 2>&1; echo "$?"` 74 | if [ $result -eq "0" ]; then 75 | echo "${target_zip} was found." 76 | break 77 | fi 78 | done 79 | 80 | wget https://dl-ssl.google.com/android/repository/${target_zip} > /dev/null 81 | 82 | if [ -e $target_zip ]; then 83 | android_os_version=`unzip -l ${target_zip} | grep android- | head -1 | grep -o -e android-[0-9.]*` 84 | 85 | unzip $target_zip -d $ANDROID_HOME/build-tools/ > /dev/null 86 | mv $ANDROID_HOME/build-tools/$android_os_version $target_dir 87 | 88 | echo "Download the ${target_zip} has been completed." 89 | ls -al ${target_dir} 90 | else 91 | echo "Failed to download the ${target_zip}." 92 | exit 1 93 | fi 94 | else 95 | echo "Existed build-tools $android_build_tools_version" 96 | ls -al ${target_dir} 97 | fi 98 | done 99 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:0.9.+' 7 | } 8 | } 9 | 10 | apply from: "gradle/commonlibrary/CommonLibrary.gradle" 11 | 12 | commonlibrary { 13 | apply project, "allprojectsSetEncoding" 14 | apply project, "allprojectsSetCompatibilityJavaVersion" 15 | apply project, "allprojectsAddConfigurationProvidedScope" 16 | 17 | // patch 18 | apply(project, "allprojectsPatchDisableLintOptionsAbortOnError") 19 | apply(project, "allprojectsPatchEnableAaptOptionsUseAaptPngCruncher") 20 | 21 | //apply project, "NeutralNexus" 22 | } 23 | 24 | ext { 25 | //mavenRepository = file("${rootDir}/repository") 26 | localPublishing = false 27 | 28 | // android sdk 29 | androidCompileSdkVersion = 19 30 | androidBuildToolsVersion = "19.0.3" 31 | androidVersion = "4.1.1.4" 32 | androidSupportVersion = "r7" 33 | 34 | // AndroidManifest.xml 35 | defaultConfigMinSdkVersion = 8 36 | defaultConfigTargetSdkVersion = 19 37 | 38 | // main dependencies 39 | ormliteVersion = "4.48" 40 | 41 | // compiler dependencies 42 | javawriterVersion = "2.4.0" 43 | springCoreVersion = "4.0.3.RELEASE" 44 | 45 | // test dependencies 46 | junitVersion = "4.11" 47 | doubleEspressoVersion = "1.1-r2" 48 | hamcrestVersion = "1.3" 49 | } 50 | 51 | allprojects { 52 | project.group = "com.tojc.ormlite.android" 53 | //project.version = "1.0.4-SNAPSHOT" 54 | project.version = "1.0.4" 55 | } 56 | 57 | //artifactId "ormlite-content-provider-parent" 58 | 59 | //apply from: "${rootDir}/pom.gradle" 60 | //customizePom { 61 | // name = "Android-OrmLiteContentProvider Parent" 62 | // description = "This is a library that easy to make using ContentProvider with OrmLite." 63 | //} 64 | 65 | apply plugin: 'android-reporting' 66 | 67 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Mar 26 01:52:34 JST 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | evaluationDependsOn(':ormlite-content-provider-library') 4 | evaluationDependsOn(':ormlite-content-provider-compiler') 5 | 6 | repositories{ 7 | mavenCentral() 8 | } 9 | 10 | commonlibrary { 11 | apply project, "addConfigurationApt" 12 | } 13 | 14 | dependencies { 15 | compile project(':ormlite-content-provider-library') 16 | apt project(':ormlite-content-provider-compiler') 17 | } 18 | 19 | android { 20 | compileSdkVersion androidCompileSdkVersion 21 | buildToolsVersion androidBuildToolsVersion 22 | 23 | buildTypes { 24 | defaultConfig { 25 | minSdkVersion defaultConfigMinSdkVersion 26 | targetSdkVersion defaultConfigTargetSdkVersion 27 | versionCode 1 28 | versionName project.version 29 | } 30 | 31 | debug { 32 | debuggable true 33 | } 34 | release { 35 | debuggable false 36 | } 37 | } 38 | 39 | sourceSets { 40 | main { 41 | manifest.srcFile 'AndroidManifest.xml' 42 | java.srcDirs = ['src', 'build/source/generated'] 43 | resources.srcDirs = ['src'] 44 | aidl.srcDirs = ['src'] 45 | renderscript.srcDirs = ['src'] 46 | res.srcDirs = ['res'] 47 | assets.srcDirs = ['assets'] 48 | } 49 | 50 | // Move the tests to tests/java, tests/res, etc... 51 | //instrumentTest.setRoot('tests') 52 | androidTest.setRoot('tests') 53 | 54 | // Move the build types to build-types/ 55 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 56 | // This moves them out of them default location under src//... which would 57 | // conflict with src/ being used by the main source set. 58 | // Adding new build types or product flavors should be accompanied 59 | // by a similar customization. 60 | debug.setRoot('build-types/debug') 61 | release.setRoot('build-types/release') 62 | } 63 | } 64 | 65 | commonlibrary { 66 | apply project, "addTaskArtifactApk" 67 | apply project, "addTaskArtifactJavadocJar" 68 | apply project, "addTaskArtifactSourceJar" 69 | 70 | apply project, "addTaskCodeQualityCheckstyle" 71 | apply project, "addTaskCodeQualityFindbugs" 72 | apply project, "addTaskCodeQualityPmd" 73 | 74 | apply project, "NeutralNexus" 75 | } 76 | 77 | checkstyle { 78 | ignoreFailures = true 79 | showViolations = false 80 | configFile = new File("$rootDir/style_checks.xml") 81 | } 82 | 83 | findbugs { 84 | ignoreFailures = true 85 | effort = "max" 86 | excludeFilter file("$projectDir/findbugs-exclude.xml") 87 | } 88 | 89 | pmd { 90 | ignoreFailures = true 91 | ruleSets = ["android", "basic", "design", "imports", "braces", "strings"] 92 | } 93 | 94 | artifacts { 95 | afterEvaluate { 96 | archives packageArtifactReleaseApk 97 | archives packageArtifactReleaseSourceJar 98 | archives packageArtifactReleaseJavadocJar 99 | } 100 | } 101 | 102 | apply from: "${rootDir}/pom.gradle" 103 | customizePom { 104 | name = "Android-OrmLiteContentProvider Sample using the annotation processor" 105 | description = "This is a project for OrmLiteContentProvider Compiler Library sample." 106 | } 107 | 108 | nexus { 109 | localPublishing = rootProject.ext.localPublishing 110 | } 111 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/findbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-compiler-sample/ic_launcher-web.png -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.tojc.ormlite.android 7 | ormlite-content-provider-parent 8 | 1.0.4-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | ormlite-content-provider-compiler-sample 13 | Android-OrmLiteContentProvider Sample using the annotation processor 14 | apk 15 | 16 | 17 | 18 | ${project.parent.basedir} 19 | 20 | 21 | 22 | 23 | com.google.android 24 | android 25 | provided 26 | 27 | 28 | com.google.android 29 | support-v4 30 | provided 31 | 32 | 33 | ${project.groupId} 34 | ormlite-content-provider-library 35 | ${project.version} 36 | apklib 37 | 38 | 39 | com.tojc.ormlite.android 40 | ormlite-content-provider-compiler 41 | ${project.version} 42 | provided 43 | 44 | 45 | 46 | 47 | src/ 48 | 49 | 50 | 70 | 71 | 72 | com.google.code.maven-replacer-plugin 73 | maven-replacer-plugin 74 | 75 | 76 | process-sources 77 | 78 | replace 79 | 80 | 81 | 82 | 83 | false 84 | target/generated-sources/r/com/tojc/ormlite/android/ormlitecontentprovider/compiler/sample/R.java 85 | target/generated-sources/r/com/tojc/ormlite/android/ormlitecontentprovider/compiler/sample/R.java 86 | false 87 | static final int 88 | static int 89 | 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-checkstyle-plugin 95 | 96 | 97 | 106 | 107 | 108 | org.apache.maven.plugins 109 | maven-pmd-plugin 110 | 111 | 112 | ${basedir}/target/generated-sources/r/ 113 | 114 | 115 | 116 | 117 | true 118 | com.jayway.maven.plugins.android.generation2 119 | android-maven-plugin 120 | 121 | 122 | 123 | maven-compiler-plugin 124 | 125 | 1.6 126 | 1.6 127 | -proc:none 128 | 129 | true 130 | 131 | 132 | org.bsc.maven 133 | maven-processor-plugin 134 | 135 | 136 | process 137 | 138 | process 139 | 140 | generate-sources 141 | 142 | 143 | com.tojc.ormlite.android.compiler.ContractAnnotationProcessor 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-18 15 | android.library.reference.1=../ormlite-content-provider-library 16 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-compiler-sample/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-compiler-sample/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-compiler-sample/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-compiler-sample/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/menu/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OrmLiteContentProviderSample 5 | Hello world! 6 | Settings 7 | 8 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/compiler/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample; 23 | 24 | import java.util.ArrayList; 25 | 26 | import android.app.Activity; 27 | import android.content.ContentProviderClient; 28 | import android.content.ContentProviderOperation; 29 | import android.content.ContentValues; 30 | import android.database.Cursor; 31 | import android.os.Bundle; 32 | import android.os.RemoteException; 33 | import android.util.Log; 34 | import android.view.Menu; 35 | 36 | import com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample.model.AccountContract; 37 | 38 | public class MainActivity extends Activity { 39 | private static final int TEST_ENTRY_COUNT = 10; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_main); 45 | 46 | // insert test 47 | ContentValues values = new ContentValues(); 48 | values.clear(); 49 | values.put(AccountContract.NAME, "Yamada Tarou"); 50 | getContentResolver().insert(AccountContract.CONTENT_URI, values); 51 | 52 | // bulkInsert test 53 | ContentValues[] contentValues = new ContentValues[TEST_ENTRY_COUNT]; 54 | for (int i = 0; i < TEST_ENTRY_COUNT; i++) { 55 | values = new ContentValues(); 56 | values.clear(); 57 | values.put(AccountContract.NAME, "Yamada Tarou: " + i); 58 | contentValues[i] = values; 59 | } 60 | getContentResolver().bulkInsert(AccountContract.CONTENT_URI, contentValues); 61 | 62 | // select test 63 | Cursor c = getContentResolver().query(AccountContract.CONTENT_URI, null, null, null, null); 64 | c.moveToFirst(); 65 | do { 66 | for (int i = 0; i < c.getColumnCount(); i++) { 67 | Log.d(getClass().getSimpleName(), c.getColumnName(i) + " : " + c.getString(i)); 68 | } 69 | } while (c.moveToNext()); 70 | c.close(); 71 | 72 | // applyBatch test 73 | ArrayList operations = new ArrayList(); 74 | operations.add(ContentProviderOperation.newInsert(AccountContract.CONTENT_URI).withValue(AccountContract.NAME, "Yamada Hanako 1").build()); 75 | operations.add(ContentProviderOperation.newInsert(AccountContract.CONTENT_URI).withValue(AccountContract.NAME, "Yamada Hanako 2").build()); 76 | try { 77 | getContentResolver().applyBatch(AccountContract.AUTHORITY, operations); 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | 82 | // ContentProviderClient test 83 | ContentProviderClient client = getContentResolver().acquireContentProviderClient(AccountContract.CONTENT_URI); 84 | Cursor c2 = null; 85 | try { 86 | c2 = client.query(AccountContract.CONTENT_URI, null, null, null, null); 87 | c2.moveToFirst(); 88 | do { 89 | for (int i = 0; i < c2.getColumnCount(); i++) { 90 | Log.d(getClass().getSimpleName(), c2.getColumnName(i) + " : " + c2.getString(i)); 91 | } 92 | } while (c2.moveToNext()); 93 | } catch (RemoteException e) { 94 | e.printStackTrace(); 95 | } finally { 96 | if (c2 != null) { 97 | c2.close(); 98 | } 99 | } 100 | client.release(); 101 | } 102 | 103 | @Override 104 | public boolean onCreateOptionsMenu(Menu menu) { 105 | // Inflate the menu; this adds items to the action bar if it is present. 106 | getMenuInflater().inflate(R.menu.activity_main, menu); 107 | return true; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/compiler/sample/model/Account.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample.model; 23 | 24 | import android.provider.BaseColumns; 25 | 26 | import com.j256.ormlite.field.DatabaseField; 27 | import com.j256.ormlite.table.DatabaseTable; 28 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 29 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 30 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 31 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 32 | 33 | /** 34 | * Did you know ? All annotations and parameters are optional ! You just need the @Contract 35 | * @author SNI 36 | */ 37 | @Contract() 38 | @DatabaseTable(tableName = "accounts") 39 | @DefaultContentUri(authority = "com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample", path = "accounts") 40 | @DefaultContentMimeTypeVnd(name = "com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample.provider", type = "accounts") 41 | public class Account { 42 | 43 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 44 | @DefaultSortOrder 45 | private int id; 46 | 47 | @DatabaseField 48 | private String name; 49 | 50 | public Account() { 51 | // ORMLite needs a no-arg constructor 52 | } 53 | 54 | public Account(String name) { 55 | this.id = 0; 56 | this.name = name; 57 | } 58 | 59 | public int getId() { 60 | return id; 61 | } 62 | 63 | public String getName() { 64 | return name; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/compiler/sample/provider/MyProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample.provider; 23 | 24 | import com.tojc.ormlite.android.OrmLiteSimpleContentProvider; 25 | import com.tojc.ormlite.android.framework.MatcherController; 26 | import com.tojc.ormlite.android.framework.MimeTypeVnd.SubType; 27 | import com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample.model.Account; 28 | import com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample.model.AccountContract; 29 | 30 | public class MyProvider extends OrmLiteSimpleContentProvider { 31 | @Override 32 | protected Class getHelperClass() { 33 | return SampleHelper.class; 34 | } 35 | 36 | @Override 37 | public boolean onCreate() { 38 | setMatcherController(new MatcherController()// 39 | .add(Account.class, SubType.DIRECTORY, "", AccountContract.CONTENT_URI_PATTERN_MANY)// 40 | .add(Account.class, SubType.ITEM, "#", AccountContract.CONTENT_URI_PATTERN_ONE)); 41 | return true; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/compiler/sample/provider/SampleHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample.provider; 23 | 24 | import java.sql.SQLException; 25 | 26 | import android.content.Context; 27 | import android.database.sqlite.SQLiteDatabase; 28 | 29 | import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; 30 | import com.j256.ormlite.support.ConnectionSource; 31 | import com.j256.ormlite.table.TableUtils; 32 | import com.tojc.ormlite.android.ormlitecontentprovider.compiler.sample.model.Account; 33 | 34 | public class SampleHelper extends OrmLiteSqliteOpenHelper { 35 | public SampleHelper(Context context) { 36 | super(context, "MyDatabase", null, 1); 37 | } 38 | 39 | @Override 40 | public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { 41 | try { 42 | TableUtils.createTableIfNotExists(connectionSource, Account.class); 43 | } catch (SQLException e) { 44 | e.printStackTrace(); 45 | } 46 | } 47 | 48 | @Override 49 | public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) { 50 | try { 51 | TableUtils.dropTable(connectionSource, Account.class, true); 52 | TableUtils.createTable(connectionSource, Account.class); 53 | } catch (SQLException e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | evaluationDependsOn(':ormlite-content-provider-library') 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | provided "com.google.android:android:${androidVersion}" 11 | 12 | compile project(path: ':ormlite-content-provider-library', configuration: 'ArtifactJar') 13 | compile "com.j256.ormlite:ormlite-core:${ormliteVersion}" 14 | compile "com.j256.ormlite:ormlite-android:${ormliteVersion}" 15 | 16 | compile "com.squareup:javawriter:${javawriterVersion}" 17 | 18 | testCompile "org.springframework:spring-core:${springCoreVersion}" 19 | testCompile "junit:junit:${junitVersion}" 20 | } 21 | 22 | 23 | def aptTestGeneratedDir = file("${buildDir}/source/generated-test") 24 | 25 | compileTestJava { 26 | doFirst { 27 | println "mkdirs : ${aptTestGeneratedDir}" 28 | aptTestGeneratedDir.mkdirs() 29 | } 30 | 31 | options.compilerArgs += ['-proc:none', '-s', aptTestGeneratedDir] 32 | } 33 | 34 | sourceSets { 35 | test { 36 | // http://forums.gradle.org/gradle/topics/classpath_order_of_test_resources_and_test_classes_while_executing_tests 37 | runtimeClasspath += files(sourceSets.test.java.srcDirs) 38 | } 39 | } 40 | 41 | commonlibrary { 42 | apply project, "addTaskArtifactJar" 43 | apply project, "addTaskArtifactJavadocJar" 44 | apply project, "addTaskArtifactSourceJar" 45 | 46 | apply project, "addTaskCodeQualityCheckstyle" 47 | apply project, "addTaskCodeQualityFindbugs" 48 | apply project, "addTaskCodeQualityPmd" 49 | 50 | apply project, "NeutralNexus" 51 | } 52 | 53 | checkstyle { 54 | ignoreFailures = false 55 | showViolations = false 56 | configFile = new File("$rootDir/style_checks.xml") 57 | } 58 | 59 | findbugs { 60 | ignoreFailures = true 61 | effort = "max" 62 | //excludeFilter file("$projectDir/findbugs-exclude.xml") 63 | } 64 | 65 | pmd { 66 | ignoreFailures = true 67 | ruleSets = ["basic", "design", "imports", "braces", "strings"] 68 | } 69 | 70 | afterEvaluate { 71 | packageArtifactJar { 72 | into('META-INF') { 73 | from 'src/main/resources/META-INF' 74 | } 75 | } 76 | } 77 | 78 | artifacts { 79 | afterEvaluate { 80 | archives packageArtifactJar 81 | archives packageArtifactSourceJar 82 | archives packageArtifactJavadocJar 83 | } 84 | } 85 | 86 | apply from: "${rootDir}/pom.gradle" 87 | customizePom { 88 | name = "Android-OrmLiteContentProvider Annotation processor" 89 | description = "Processes annotations to create a ContentProvider with OrmLite." 90 | } 91 | 92 | nexus { 93 | localPublishing = rootProject.ext.localPublishing 94 | } 95 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/javadoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.tojc.ormlite.android 7 | ormlite-content-provider-parent 8 | 1.0.4-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | ormlite-content-provider-compiler 13 | Android-OrmLiteContentProvider Annotation processor 14 | jar 15 | Processes annotations to create a ContentProvider with OrmLite. 16 | 17 | 18 | 19 | ${project.parent.basedir} 20 | 21 | 22 | 23 | 24 | com.google.android 25 | android 26 | provided 27 | 28 | 29 | com.squareup 30 | javawriter 31 | 32 | 33 | ${project.groupId} 34 | ormlite-content-provider-library 35 | ${project.version} 36 | 37 | 38 | org.springframework 39 | spring-core 40 | test 41 | 42 | 43 | junit 44 | junit 45 | 46 | 47 | 48 | 49 | 50 | 51 | ${basedir}/src/test/resources 52 | 53 | 54 | 56 | 57 | ${project.build.testSourceDirectory}/com/tojc/ormlite/android/compiler/sample 58 | com/tojc/ormlite/android/compiler/sample 59 | 60 | 61 | 62 | 63 | org.apache.maven.plugins 64 | maven-checkstyle-plugin 65 | 66 | 67 | org.codehaus.mojo 68 | findbugs-maven-plugin 69 | 70 | 71 | org.apache.maven.plugins 72 | maven-pmd-plugin 73 | 74 | 75 | ${basedir}/target/generated-sources/r/ 76 | 77 | 78 | 79 | 80 | org.apache.maven.plugins 81 | maven-compiler-plugin 82 | 83 | -proc:none 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-17 15 | android.library=true 16 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | com.tojc.ormlite.android.compiler.ContractAnnotationProcessor -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/CombinedPojo1.java: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.provider.BaseColumns; 4 | import com.j256.ormlite.field.DatabaseField; 5 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 6 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 7 | 8 | @Contract(contractClassName = "com.tojc.ormlite.android.compiler.sample.CombinedPojoContract1") 9 | public class CombinedPojo1 { 10 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 11 | @DefaultSortOrder 12 | private int id; 13 | 14 | @DatabaseField 15 | private String name; 16 | } 17 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/CombinedPojo2.java: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.provider.BaseColumns; 4 | import com.j256.ormlite.field.DatabaseField; 5 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 6 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 7 | 8 | @Contract(contractClassName = "com.tojc.ormlite.android.compiler.sample.CombinedPojoContract1") 9 | public class CombinedPojo2 { 10 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 11 | @DefaultSortOrder 12 | private int id; 13 | 14 | @DatabaseField 15 | private String name; 16 | } 17 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/CombinedPojo3.java: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.provider.BaseColumns; 4 | import com.j256.ormlite.field.DatabaseField; 5 | import com.j256.ormlite.table.DatabaseTable; 6 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 7 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 8 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 9 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 10 | 11 | @Contract(contractClassName = "com.tojc.ormlite.android.compiler.sample.CombinedPojoContract2") 12 | @DefaultContentUri(authority = "com.tojc.ormlite.android.compiler.samplepojo", path = "my_pojo_3") 13 | @DefaultContentMimeTypeVnd(name = "pojo3", type = "pojo3") 14 | @DatabaseTable(tableName = "pojo3") 15 | public class CombinedPojo3 { 16 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 17 | @DefaultSortOrder 18 | private int id; 19 | 20 | @DatabaseField 21 | private String name; 22 | } 23 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/CombinedPojo4.java: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.provider.BaseColumns; 4 | import com.j256.ormlite.field.DatabaseField; 5 | import com.j256.ormlite.table.DatabaseTable; 6 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 7 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 8 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 9 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 10 | 11 | @Contract(contractClassName = "com.tojc.ormlite.android.compiler.sample.CombinedPojoContract2") 12 | @DefaultContentUri(authority = "com.tojc.ormlite.android.compiler.samplepojo", path = "my_pojo_4") 13 | @DefaultContentMimeTypeVnd(name = "pojo4", type = "pojo4") 14 | @DatabaseTable(tableName = "pojo4") 15 | public class CombinedPojo4 { 16 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 17 | @DefaultSortOrder 18 | private int id; 19 | 20 | @DatabaseField 21 | private String name; 22 | } 23 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/CombinedPojo5.java: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.provider.BaseColumns; 4 | import com.j256.ormlite.field.DatabaseField; 5 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 6 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 7 | 8 | @Contract(contractClassName = "com.tojc.ormlite.android.compiler.sample.CombinedPojoContract3") 9 | public class CombinedPojo5 { 10 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 11 | @DefaultSortOrder 12 | private int id; 13 | 14 | @DatabaseField 15 | private String name; 16 | } 17 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/CombinedPojo6.java: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.provider.BaseColumns; 4 | import com.j256.ormlite.field.DatabaseField; 5 | import com.j256.ormlite.table.DatabaseTable; 6 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 7 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 8 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 9 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 10 | 11 | @Contract(contractClassName = "com.tojc.ormlite.android.compiler.sample.CombinedPojoContract3") 12 | @DefaultContentUri(authority = "com.tojc.ormlite.android.compiler.samplepojo", path = "my_pojo_3") 13 | @DefaultContentMimeTypeVnd(name = "pojo3", type = "pojo3") 14 | @DatabaseTable(tableName = "pojo3") 15 | public class CombinedPojo6 { 16 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 17 | @DefaultSortOrder 18 | private int id; 19 | 20 | @DatabaseField 21 | private String name; 22 | } 23 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/Pojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.compiler.sample; 23 | 24 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 25 | 26 | /** 27 | * A very simple sample to be tested. 28 | * @author SNI 29 | */ 30 | @Contract 31 | public class Pojo { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/Pojo2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.compiler.sample; 23 | 24 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 25 | 26 | /** 27 | * A less simple sample to be tested. 28 | * @author SNI 29 | */ 30 | @Contract(contractClassName = "com.tojc.ormlite.android.compiler.sample.LessSimplePojoContract2") 31 | public class Pojo2 { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/Pojo3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.compiler.sample; 23 | 24 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 25 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 26 | 27 | /** 28 | * A sample to be tested with @ContentUri 29 | * @author SNI 30 | */ 31 | @Contract() 32 | @DefaultContentUri(authority = "com.tojc.ormlite.android.compiler.sample3", path = "get_lucky_from_daft_punk") 33 | public class Pojo3 { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/Pojo4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.compiler.sample; 23 | 24 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 25 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 26 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 27 | 28 | /** 29 | * A sample to be tested with @ContentUri and @DefaultContentMimeTypeVnd 30 | * @author SNI 31 | */ 32 | @Contract() 33 | @DefaultContentUri(authority = "com.tojc.ormlite.android.compiler.sample", path = "get_lucky_from_daft_punk") 34 | @DefaultContentMimeTypeVnd(name = "c2c", type = "tetra") 35 | public class Pojo4 { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/com/tojc/ormlite/android/compiler/sample/PojoWithFields1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.compiler.sample; 23 | 24 | import com.j256.ormlite.field.DatabaseField; 25 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.Contract; 26 | 27 | /** 28 | * A sample to be tested with fields. One is contractual, not the other. 29 | * @author SNI 30 | */ 31 | @Contract() 32 | public class PojoWithFields1 { 33 | 34 | @SuppressWarnings("unused") 35 | private String nonContractualField; 36 | 37 | @DatabaseField 38 | private String contractualField; 39 | } 40 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/java/dummy.txt: -------------------------------------------------------------------------------- 1 | Empty file so that git save the folder in its tree. 2 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/resources/com/tojc/ormlite/android/compiler/sample/CombinedPojoContract1.javasource: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.net.Uri; 4 | import android.content.ContentResolver; 5 | import android.provider.BaseColumns; 6 | 7 | public final class CombinedPojoContract1 { 8 | private static final String CONTRACT_AUTHORITY = "com.tojc.ormlite.android.compiler.sample"; 9 | private static final String CONTRACT_MIME_TYPE_NAME = "com.tojc.ormlite.android.compiler.sample.provider"; 10 | 11 | private CombinedPojoContract1() { 12 | } 13 | 14 | public static final class CombinedPojo1 15 | implements BaseColumns { 16 | public static final String TABLE_NAME = "CombinedPojo1"; 17 | 18 | public static final String CONTENT_URI_PATH = "combinedpojo1"; 19 | public static final String AUTHORITY = CONTRACT_AUTHORITY; 20 | 21 | public static final String MIMETYPE_TYPE = "combinedpojo1"; 22 | public static final String MIMETYPE_NAME = CONTRACT_MIME_TYPE_NAME; 23 | 24 | public static final int CONTENT_URI_PATTERN_MANY = 1; 25 | public static final int CONTENT_URI_PATTERN_ONE = 2; 26 | 27 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 28 | 29 | private CombinedPojo1() { 30 | } 31 | 32 | public static final String NAME = "name"; 33 | } 34 | 35 | public static final class CombinedPojo2 36 | implements BaseColumns { 37 | public static final String TABLE_NAME = "CombinedPojo2"; 38 | 39 | public static final String CONTENT_URI_PATH = "combinedpojo2"; 40 | public static final String AUTHORITY = CONTRACT_AUTHORITY; 41 | 42 | public static final String MIMETYPE_TYPE = "combinedpojo2"; 43 | public static final String MIMETYPE_NAME = CONTRACT_MIME_TYPE_NAME; 44 | 45 | public static final int CONTENT_URI_PATTERN_MANY = 3; 46 | public static final int CONTENT_URI_PATTERN_ONE = 4; 47 | 48 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 49 | 50 | private CombinedPojo2() { 51 | } 52 | 53 | public static final String NAME = "name"; 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/resources/com/tojc/ormlite/android/compiler/sample/CombinedPojoContract2.javasource: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.net.Uri; 4 | import android.content.ContentResolver; 5 | import android.provider.BaseColumns; 6 | 7 | public final class CombinedPojoContract2 { 8 | private static final String CONTRACT_AUTHORITY = "com.tojc.ormlite.android.compiler.sample"; 9 | private static final String CONTRACT_MIME_TYPE_NAME = "com.tojc.ormlite.android.compiler.sample.provider"; 10 | 11 | private CombinedPojoContract2() { 12 | } 13 | 14 | public static final class CombinedPojo3 15 | implements BaseColumns { 16 | public static final String TABLE_NAME = "pojo3"; 17 | 18 | public static final String CONTENT_URI_PATH = "my_pojo_3"; 19 | public static final String AUTHORITY = "com.tojc.ormlite.android.compiler.samplepojo"; 20 | 21 | public static final String MIMETYPE_TYPE = "pojo3"; 22 | public static final String MIMETYPE_NAME = "pojo3"; 23 | 24 | public static final int CONTENT_URI_PATTERN_MANY = 1; 25 | public static final int CONTENT_URI_PATTERN_ONE = 2; 26 | 27 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 28 | 29 | private CombinedPojo3() { 30 | } 31 | 32 | public static final String NAME = "name"; 33 | } 34 | 35 | public static final class CombinedPojo4 36 | implements BaseColumns { 37 | public static final String TABLE_NAME = "pojo4"; 38 | 39 | public static final String CONTENT_URI_PATH = "my_pojo_4"; 40 | public static final String AUTHORITY = "com.tojc.ormlite.android.compiler.samplepojo"; 41 | 42 | public static final String MIMETYPE_TYPE = "pojo4"; 43 | public static final String MIMETYPE_NAME = "pojo4"; 44 | 45 | public static final int CONTENT_URI_PATTERN_MANY = 3; 46 | public static final int CONTENT_URI_PATTERN_ONE = 4; 47 | 48 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 49 | 50 | private CombinedPojo4() { 51 | } 52 | 53 | public static final String NAME = "name"; 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/resources/com/tojc/ormlite/android/compiler/sample/CombinedPojoContract3.javasource: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.net.Uri; 4 | import android.content.ContentResolver; 5 | import android.provider.BaseColumns; 6 | 7 | public final class CombinedPojoContract3 { 8 | private static final String CONTRACT_AUTHORITY = "com.tojc.ormlite.android.compiler.sample"; 9 | private static final String CONTRACT_MIME_TYPE_NAME = "com.tojc.ormlite.android.compiler.sample.provider"; 10 | 11 | private CombinedPojoContract3() { 12 | } 13 | 14 | public static final class CombinedPojo5 15 | implements BaseColumns { 16 | public static final String TABLE_NAME = "CombinedPojo5"; 17 | 18 | public static final String CONTENT_URI_PATH = "combinedpojo5"; 19 | public static final String AUTHORITY = CONTRACT_AUTHORITY; 20 | 21 | public static final String MIMETYPE_TYPE = "combinedpojo5"; 22 | public static final String MIMETYPE_NAME = CONTRACT_MIME_TYPE_NAME; 23 | 24 | public static final int CONTENT_URI_PATTERN_MANY = 1; 25 | public static final int CONTENT_URI_PATTERN_ONE = 2; 26 | 27 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 28 | 29 | private CombinedPojo5() { 30 | } 31 | 32 | public static final String NAME = "name"; 33 | } 34 | 35 | public static final class CombinedPojo6 36 | implements BaseColumns { 37 | public static final String TABLE_NAME = "pojo3"; 38 | 39 | public static final String CONTENT_URI_PATH = "my_pojo_3"; 40 | public static final String AUTHORITY = "com.tojc.ormlite.android.compiler.samplepojo"; 41 | 42 | public static final String MIMETYPE_TYPE = "pojo3"; 43 | public static final String MIMETYPE_NAME = "pojo3"; 44 | 45 | public static final int CONTENT_URI_PATTERN_MANY = 3; 46 | public static final int CONTENT_URI_PATTERN_ONE = 4; 47 | 48 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 49 | 50 | private CombinedPojo6() { 51 | } 52 | 53 | public static final String NAME = "name"; 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/resources/com/tojc/ormlite/android/compiler/sample/LessSimplePojoContract2.javasource: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.net.Uri; 4 | import android.content.ContentResolver; 5 | import android.provider.BaseColumns; 6 | 7 | public final class LessSimplePojoContract2 8 | implements BaseColumns { 9 | public static final String TABLE_NAME = "Pojo2"; 10 | 11 | public static final String CONTENT_URI_PATH = "pojo2"; 12 | public static final String AUTHORITY = "com.tojc.ormlite.android.compiler.sample"; 13 | 14 | public static final String MIMETYPE_TYPE = "pojo2"; 15 | public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.compiler.sample.provider"; 16 | 17 | public static final int CONTENT_URI_PATTERN_MANY = 1; 18 | public static final int CONTENT_URI_PATTERN_ONE = 2; 19 | 20 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 21 | 22 | private LessSimplePojoContract2() { 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/resources/com/tojc/ormlite/android/compiler/sample/Pojo3Contract.javasource: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.net.Uri; 4 | import android.content.ContentResolver; 5 | import android.provider.BaseColumns; 6 | 7 | public final class Pojo3Contract 8 | implements BaseColumns { 9 | public static final String TABLE_NAME = "Pojo3"; 10 | 11 | public static final String CONTENT_URI_PATH = "get_lucky_from_daft_punk"; 12 | public static final String AUTHORITY = "com.tojc.ormlite.android.compiler.sample3"; 13 | 14 | public static final String MIMETYPE_TYPE = "pojo3"; 15 | public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.compiler.sample.provider"; 16 | 17 | public static final int CONTENT_URI_PATTERN_MANY = 1; 18 | public static final int CONTENT_URI_PATTERN_ONE = 2; 19 | 20 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 21 | 22 | private Pojo3Contract() { 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/resources/com/tojc/ormlite/android/compiler/sample/Pojo4Contract.javasource: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.net.Uri; 4 | import android.content.ContentResolver; 5 | import android.provider.BaseColumns; 6 | 7 | public final class Pojo4Contract 8 | implements BaseColumns { 9 | public static final String TABLE_NAME = "Pojo4"; 10 | 11 | public static final String CONTENT_URI_PATH = "get_lucky_from_daft_punk"; 12 | public static final String AUTHORITY = "com.tojc.ormlite.android.compiler.sample"; 13 | 14 | public static final String MIMETYPE_TYPE = "tetra"; 15 | public static final String MIMETYPE_NAME = "c2c"; 16 | 17 | public static final int CONTENT_URI_PATTERN_MANY = 1; 18 | public static final int CONTENT_URI_PATTERN_ONE = 2; 19 | 20 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 21 | 22 | private Pojo4Contract() { 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/resources/com/tojc/ormlite/android/compiler/sample/PojoContract.javasource: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.net.Uri; 4 | import android.content.ContentResolver; 5 | import android.provider.BaseColumns; 6 | 7 | public final class PojoContract 8 | implements BaseColumns { 9 | public static final String TABLE_NAME = "Pojo"; 10 | 11 | public static final String CONTENT_URI_PATH = "pojo"; 12 | public static final String AUTHORITY = "com.tojc.ormlite.android.compiler.sample"; 13 | 14 | public static final String MIMETYPE_TYPE = "pojo"; 15 | public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.compiler.sample.provider"; 16 | 17 | public static final int CONTENT_URI_PATTERN_MANY = 1; 18 | public static final int CONTENT_URI_PATTERN_ONE = 2; 19 | 20 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 21 | 22 | private PojoContract() { 23 | } 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /ormlite-content-provider-compiler/src/test/resources/com/tojc/ormlite/android/compiler/sample/PojoWithFields1Contract.javasource: -------------------------------------------------------------------------------- 1 | package com.tojc.ormlite.android.compiler.sample; 2 | 3 | import android.net.Uri; 4 | import android.content.ContentResolver; 5 | import android.provider.BaseColumns; 6 | 7 | public final class PojoWithFields1Contract 8 | implements BaseColumns { 9 | public static final String TABLE_NAME = "PojoWithFields1"; 10 | 11 | public static final String CONTENT_URI_PATH = "pojowithfields1"; 12 | public static final String AUTHORITY = "com.tojc.ormlite.android.compiler.sample"; 13 | 14 | public static final String MIMETYPE_TYPE = "pojowithfields1"; 15 | public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.compiler.sample.provider"; 16 | 17 | public static final int CONTENT_URI_PATTERN_MANY = 1; 18 | public static final int CONTENT_URI_PATTERN_ONE = 2; 19 | 20 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 21 | 22 | private PojoWithFields1Contract() { 23 | } 24 | 25 | public static final String CONTRACTUALFIELD = "contractualField"; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 17 | 18 | 21 | 22 | 23 | 26 | 27 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | evaluationDependsOn(':ormlite-content-provider-library') 4 | 5 | repositories{ 6 | mavenCentral() 7 | maven { 8 | url 'https://oss.sonatype.org/content/repositories/snapshots/' 9 | } 10 | } 11 | 12 | dependencies { 13 | compile project(":ormlite-content-provider-library") 14 | 15 | androidTestCompile project(":ormlite-content-provider-library") 16 | 17 | androidTestCompile "junit:junit:${junitVersion}" 18 | androidTestCompile("com.jakewharton.espresso:espresso:${doubleEspressoVersion}") { 19 | exclude group: "org.hamcrest" 20 | } 21 | androidTestCompile "org.hamcrest:hamcrest-core:${hamcrestVersion}" 22 | androidTestCompile "org.hamcrest:hamcrest-library:${hamcrestVersion}" 23 | androidTestCompile "org.hamcrest:hamcrest-integration:${hamcrestVersion}" 24 | } 25 | 26 | android { 27 | compileSdkVersion androidCompileSdkVersion 28 | buildToolsVersion androidBuildToolsVersion 29 | 30 | buildTypes { 31 | defaultConfig { 32 | minSdkVersion defaultConfigMinSdkVersion 33 | targetSdkVersion defaultConfigTargetSdkVersion 34 | versionCode 1 35 | versionName project.version 36 | 37 | testPackageName "com.tojc.ormlite.android.test" 38 | testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" 39 | testFunctionalTest true 40 | } 41 | 42 | debug { 43 | debuggable true 44 | } 45 | release { 46 | debuggable false 47 | runProguard false 48 | } 49 | } 50 | 51 | sourceSets { 52 | main { 53 | manifest.srcFile 'AndroidManifest.xml' 54 | java.srcDirs = ['src', 'build/source/generated'] 55 | resources.srcDirs = ['src'] 56 | aidl.srcDirs = ['src'] 57 | renderscript.srcDirs = ['src'] 58 | res.srcDirs = ['res'] 59 | assets.srcDirs = ['assets'] 60 | } 61 | 62 | // Move the tests to tests/java, tests/res, etc... 63 | //instrumentTest.setRoot('tests') 64 | //androidTest.setRoot('tests') 65 | androidTest { 66 | manifest.srcFile 'AndroidManifest.xml' 67 | java.srcDirs = ['src', 'build/source/generated'] 68 | resources.srcDirs = ['src'] 69 | aidl.srcDirs = ['src'] 70 | renderscript.srcDirs = ['src'] 71 | res.srcDirs = ['res'] 72 | assets.srcDirs = ['assets'] 73 | } 74 | 75 | // Move the build types to build-types/ 76 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 77 | // This moves them out of them default location under src//... which would 78 | // conflict with src/ being used by the main source set. 79 | // Adding new build types or product flavors should be accompanied 80 | // by a similar customization. 81 | debug.setRoot('build-types/debug') 82 | release.setRoot('build-types/release') 83 | } 84 | 85 | packagingOptions { 86 | // hamcrest-core-1.3.jar 87 | // for AndroidStudio's bug. duplication error of file below. 88 | pickFirst 'META-INF/LICENSE.txt' 89 | pickFirst 'LICENSE.txt' 90 | } 91 | } 92 | 93 | commonlibrary { 94 | apply project, "addTaskArtifactApk" 95 | apply project, "addTaskArtifactJavadocJar" 96 | apply project, "addTaskArtifactSourceJar" 97 | 98 | apply project, "addTaskCodeQualityCheckstyle" 99 | apply project, "addTaskCodeQualityFindbugs" 100 | apply project, "addTaskCodeQualityPmd" 101 | 102 | apply project, "NeutralNexus" 103 | } 104 | 105 | checkstyle { 106 | ignoreFailures = true 107 | showViolations = false 108 | configFile = new File("$rootDir/style_checks.xml") 109 | } 110 | 111 | findbugs { 112 | ignoreFailures = true 113 | effort = "max" 114 | excludeFilter file("$projectDir/findbugs-exclude.xml") 115 | } 116 | 117 | pmd { 118 | ignoreFailures = true 119 | ruleSets = ["android", "basic", "design", "imports", "braces", "strings"] 120 | } 121 | 122 | artifacts { 123 | afterEvaluate { 124 | archives packageArtifactReleaseApk 125 | archives packageArtifactReleaseSourceJar 126 | archives packageArtifactReleaseJavadocJar 127 | } 128 | } 129 | 130 | apply from: "${rootDir}/pom.gradle" 131 | customizePom { 132 | name = "Android-OrmLiteContentProvider Tests" 133 | description = "This is a project for OrmLiteContentProvider Library test." 134 | } 135 | 136 | nexus { 137 | localPublishing = rootProject.ext.localPublishing 138 | } 139 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/findbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-library-test/ic_launcher-web.png -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.tojc.ormlite.android 7 | ormlite-content-provider-parent 8 | 1.0.4-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | ormlite-content-provider-library-test 13 | Android-OrmLiteContentProvider Tests 14 | apk 15 | 16 | 17 | 18 | ${project.parent.basedir} 19 | 20 | 21 | 22 | 23 | com.google.android 24 | android 25 | provided 26 | 27 | 28 | com.google.android 29 | android-test 30 | provided 31 | 32 | 33 | com.google.android 34 | support-v4 35 | provided 36 | 37 | 38 | ${project.groupId} 39 | ormlite-content-provider-library 40 | ${project.version} 41 | apklib 42 | 43 | 44 | junit 45 | junit 46 | provided 47 | 48 | 49 | 50 | 51 | src/ 52 | 53 | 54 | org.apache.maven.plugins 55 | maven-checkstyle-plugin 56 | 57 | 58 | 59 | com.google.code.maven-replacer-plugin 60 | maven-replacer-plugin 61 | 62 | 63 | process-sources 64 | 65 | replace 66 | 67 | 68 | 69 | 70 | false 71 | target/generated-sources/r/com/tojc/ormlite/android/test/R.java 72 | target/generated-sources/r/com/tojc/ormlite/android/test/R.java 73 | false 74 | static final int 75 | static int 76 | 77 | 78 | 79 | 88 | 89 | 90 | org.apache.maven.plugins 91 | maven-pmd-plugin 92 | 93 | 94 | ${basedir}/target/generated-sources/r/ 95 | 96 | 97 | 98 | 99 | true 100 | com.jayway.maven.plugins.android.generation2 101 | android-maven-plugin 102 | 103 | 104 | maven-compiler-plugin 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-18 15 | android.library.reference.1=../ormlite-content-provider-library 16 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-library-test/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-library-test/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-library-test/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-library-test/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/menu/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OrmLiteContentProviderSample 5 | Hello world! 6 | Settings 7 | 8 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/annotation/info/AnnotationInfoBaseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation.info; 23 | 24 | import android.test.AndroidTestCase; 25 | import android.test.suitebuilder.annotation.SmallTest; 26 | 27 | @SmallTest 28 | public class AnnotationInfoBaseTest extends AndroidTestCase { 29 | 30 | private DummyAnnotationInfoBase dummyAnnotationInfoBase; 31 | 32 | public void testIsValid_should_return_false_until_validated() { 33 | // given 34 | dummyAnnotationInfoBase = new DummyAnnotationInfoBase(true); 35 | 36 | // when 37 | 38 | // then 39 | assertFalse(dummyAnnotationInfoBase.isValid()); 40 | 41 | // when 42 | dummyAnnotationInfoBase.validate(); 43 | 44 | // then 45 | assertTrue(dummyAnnotationInfoBase.isValid()); 46 | } 47 | 48 | public void testIsValid_throws_exception_or_not() { 49 | // given 50 | dummyAnnotationInfoBase = new DummyAnnotationInfoBase(true); 51 | 52 | // when 53 | 54 | // then 55 | assertFalse(dummyAnnotationInfoBase.isValid(false)); 56 | 57 | // when 58 | 59 | // then 60 | try { 61 | dummyAnnotationInfoBase.isValid(true); 62 | fail(); 63 | } catch (Exception ex) { 64 | assertTrue(true); 65 | } 66 | } 67 | 68 | /** 69 | * Class under test. 70 | * @author SNI 71 | */ 72 | private static class DummyAnnotationInfoBase extends AnnotationInfoBase { 73 | 74 | private boolean isValidValue; 75 | 76 | public DummyAnnotationInfoBase(boolean isValidValue) { 77 | this.isValidValue = isValidValue; 78 | } 79 | 80 | public void validate() { 81 | validFlagOn(); 82 | } 83 | 84 | @Override 85 | protected boolean isValidValue() { 86 | return isValidValue; 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return "DummyAnnotationInfoBase{" 92 | + "isValidValue=" + isValidValue 93 | + "} " + super.toString(); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/annotation/info/ContentUriInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation.info; 23 | 24 | import java.util.Locale; 25 | 26 | import android.test.AndroidTestCase; 27 | import android.test.suitebuilder.annotation.SmallTest; 28 | 29 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 30 | 31 | @SmallTest 32 | public class ContentUriInfoTest extends AndroidTestCase { 33 | 34 | private static final String TEST_AUTHORITY = "foo"; 35 | private static final String TEST_PATH = "bar"; 36 | private static final String EMPTY = ""; 37 | 38 | private ContentUriInfo contentUriInfo; 39 | 40 | public void testIsValidValue_returns_false_for_null_or_empty_package_or_class() { 41 | // given 42 | contentUriInfo = new ContentUriInfo(null, null); 43 | // when 44 | 45 | // then 46 | assertFalse(contentUriInfo.isValidValue()); 47 | 48 | // -- 49 | // given 50 | contentUriInfo = new ContentUriInfo(null, TEST_PATH); 51 | // when 52 | 53 | // then 54 | assertFalse(contentUriInfo.isValidValue()); 55 | 56 | // -- 57 | // given 58 | contentUriInfo = new ContentUriInfo(TEST_AUTHORITY, null); 59 | // when 60 | 61 | // then 62 | assertFalse(contentUriInfo.isValidValue()); 63 | 64 | // -- 65 | // given 66 | contentUriInfo = new ContentUriInfo(TEST_AUTHORITY, EMPTY); 67 | // when 68 | 69 | // then 70 | assertFalse(contentUriInfo.isValidValue()); 71 | 72 | // -- 73 | // given 74 | contentUriInfo = new ContentUriInfo(EMPTY, TEST_PATH); 75 | // when 76 | 77 | // then 78 | assertFalse(contentUriInfo.isValidValue()); 79 | } 80 | 81 | public void testIsValidValue_returns_true() { 82 | // given 83 | contentUriInfo = new ContentUriInfo(TEST_AUTHORITY, TEST_PATH); 84 | // when 85 | 86 | // then 87 | assertTrue(contentUriInfo.isValidValue()); 88 | } 89 | 90 | public void testgetAuthority() { 91 | // given 92 | contentUriInfo = new ContentUriInfo(TEST_AUTHORITY, TEST_PATH); 93 | // when 94 | 95 | // then 96 | assertEquals(TEST_AUTHORITY, contentUriInfo.getAuthority()); 97 | } 98 | 99 | public void testgetPath() { 100 | // given 101 | contentUriInfo = new ContentUriInfo(TEST_AUTHORITY, TEST_PATH); 102 | // when 103 | 104 | // then 105 | assertEquals(TEST_PATH, contentUriInfo.getPath()); 106 | } 107 | 108 | public void testIsValidValue_returns_right_values_for_annotated_element_without_params() { 109 | // given 110 | contentUriInfo = new ContentUriInfo(AnnotatedClassUnderTestNoParams.class); 111 | // when 112 | 113 | // then 114 | assertEquals(AnnotatedClassUnderTestNoParams.class.getPackage().getName(), contentUriInfo.getAuthority()); 115 | assertEquals(AnnotatedClassUnderTestNoParams.class.getSimpleName().toLowerCase(Locale.ENGLISH), contentUriInfo.getPath()); 116 | assertTrue(contentUriInfo.isValidValue()); 117 | } 118 | 119 | public void testIsValidValue_returns_right_values_for_annotated_element_with_params() { 120 | // given 121 | contentUriInfo = new ContentUriInfo(AnnotatedClassUnderTestWithParams.class); 122 | // when 123 | 124 | // then 125 | assertEquals(TEST_AUTHORITY, contentUriInfo.getAuthority()); 126 | assertEquals(TEST_PATH, contentUriInfo.getPath()); 127 | assertTrue(contentUriInfo.isValidValue()); 128 | } 129 | 130 | public void testIsValidValue_returns_right_values_for_non_annotated_element() { 131 | // given 132 | contentUriInfo = new ContentUriInfo(NonAnnotatedClassUnderTest.class); 133 | // when 134 | 135 | // then 136 | assertEquals(NonAnnotatedClassUnderTest.class.getPackage().getName(), contentUriInfo.getAuthority()); 137 | assertEquals(NonAnnotatedClassUnderTest.class.getSimpleName().toLowerCase(Locale.ENGLISH), contentUriInfo.getPath()); 138 | assertTrue(contentUriInfo.isValidValue()); 139 | } 140 | 141 | /** 142 | * Annotated class under test. 143 | */ 144 | @DefaultContentUri 145 | private class AnnotatedClassUnderTestNoParams { 146 | } 147 | 148 | /** 149 | * Annotated class under test. 150 | */ 151 | @DefaultContentUri(authority = TEST_AUTHORITY, path = TEST_PATH) 152 | private class AnnotatedClassUnderTestWithParams { 153 | } 154 | 155 | /** 156 | * Non-Annotated class under test. 157 | */ 158 | private class NonAnnotatedClassUnderTest { 159 | } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/framework/ColumnInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.framework; 23 | 24 | import java.lang.reflect.Field; 25 | 26 | import android.test.AndroidTestCase; 27 | import android.test.suitebuilder.annotation.SmallTest; 28 | 29 | import com.j256.ormlite.field.DatabaseField; 30 | 31 | @SmallTest 32 | public class ColumnInfoTest extends AndroidTestCase { 33 | private static final String TEST_FIELD_NAME = "annotatedField"; 34 | private static final String EMPTY = ""; 35 | private ColumnInfo columnInfo; 36 | 37 | public void testIsValid_returns_true_when_field_has_empty_column_name() throws NoSuchFieldException { 38 | 39 | // given 40 | Field field = ClassUnderTest.class.getDeclaredField("annotatedFieldWithEmptyColumnName"); 41 | 42 | // when 43 | columnInfo = new ColumnInfo(field); 44 | 45 | // then 46 | assertTrue(columnInfo.isValid()); 47 | } 48 | 49 | public void testIsValid_returns_true_when_field_has_no_column_name() throws NoSuchFieldException { 50 | 51 | // given 52 | Field field = ClassUnderTest.class.getDeclaredField("annotatedField"); 53 | 54 | // when 55 | columnInfo = new ColumnInfo(field); 56 | 57 | // then 58 | assertTrue(columnInfo.isValid()); 59 | } 60 | 61 | public void testIsValid_returns_true_when_field_has_column_name() throws NoSuchFieldException { 62 | 63 | // given 64 | Field field = ClassUnderTest.class.getDeclaredField("annotatedFieldWithParams"); 65 | 66 | // when 67 | columnInfo = new ColumnInfo(field); 68 | 69 | // then 70 | assertTrue(columnInfo.isValid()); 71 | } 72 | 73 | public void testConstructor_throws_exception_when_field_is_not_annotated() throws NoSuchFieldException { 74 | 75 | // given 76 | Field field = ClassUnderTest.class.getDeclaredField("nonAnnotatedField"); 77 | 78 | // when 79 | 80 | // then 81 | try { 82 | columnInfo = new ColumnInfo(field); 83 | fail(); 84 | } catch (Exception e) { 85 | assertTrue(true); 86 | } 87 | } 88 | 89 | public void testGetProjectionColumnName_returns_field_name_when_has_no_column_name() throws NoSuchFieldException { 90 | // given 91 | Field field = ClassUnderTest.class.getDeclaredField(TEST_FIELD_NAME); 92 | 93 | // when 94 | columnInfo = new ColumnInfo(field); 95 | 96 | // then 97 | assertEquals(TEST_FIELD_NAME, columnInfo.getColumnName()); 98 | } 99 | 100 | public void testGetProjectionColumnName_returns_field_name_when_has_column_name() throws NoSuchFieldException { 101 | // given 102 | Field field = ClassUnderTest.class.getDeclaredField(TEST_FIELD_NAME); 103 | 104 | // when 105 | columnInfo = new ColumnInfo(field); 106 | 107 | // then 108 | assertEquals(TEST_FIELD_NAME, columnInfo.getColumnName()); 109 | } 110 | 111 | public void testGetProjectionColumnName_returns_field_name_when_has_empty_column_name() throws NoSuchFieldException { 112 | final String testFieldName = "annotatedFieldWithEmptyColumnName"; 113 | // given 114 | Field field = ClassUnderTest.class.getDeclaredField(testFieldName); 115 | 116 | // when 117 | columnInfo = new ColumnInfo(field); 118 | 119 | // then 120 | assertEquals(testFieldName, columnInfo.getColumnName()); 121 | } 122 | 123 | // ---------------------------------- 124 | // CLASSES UNDER TEST 125 | // ---------------------------------- 126 | @SuppressWarnings("unused") 127 | private class ClassUnderTest { 128 | 129 | private String nonAnnotatedField; 130 | 131 | @DatabaseField 132 | private String annotatedField; 133 | 134 | @DatabaseField(columnName = EMPTY) 135 | private String annotatedFieldWithEmptyColumnName; 136 | 137 | @DatabaseField(columnName = TEST_FIELD_NAME) 138 | private String annotatedFieldWithParams; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/framework/MimeTypeVndTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.framework; 23 | 24 | import java.io.File; 25 | 26 | import android.test.AndroidTestCase; 27 | import android.test.suitebuilder.annotation.SmallTest; 28 | 29 | import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo; 30 | import com.tojc.ormlite.android.framework.MimeTypeVnd.SubType; 31 | 32 | @SmallTest 33 | public class MimeTypeVndTest extends AndroidTestCase { 34 | 35 | private static final String CONTENT_MIME_TYPE_VND_NAME = "bar"; 36 | private static final String CONTENT_MIME_TYPE_VND_TYPE = "foo"; 37 | private static final String EMPTY = ""; 38 | 39 | private MimeTypeVnd mimeTypeVnd; 40 | 41 | public void testIsValid_returns_false_if_subtype_is_null() { 42 | // given 43 | mimeTypeVnd = new MimeTypeVnd(null, new ContentMimeTypeVndInfo(CONTENT_MIME_TYPE_VND_NAME, CONTENT_MIME_TYPE_VND_TYPE)); 44 | // when 45 | 46 | // then 47 | assertFalse(mimeTypeVnd.isValid()); 48 | } 49 | 50 | public void testIsValid_returns_false_if_mime_type_has_null_or_empty_path() { 51 | // given 52 | mimeTypeVnd = new MimeTypeVnd(SubType.ITEM, new ContentMimeTypeVndInfo(null, CONTENT_MIME_TYPE_VND_TYPE)); 53 | // when 54 | 55 | // then 56 | assertFalse(mimeTypeVnd.isValid()); 57 | 58 | // -- 59 | // given 60 | mimeTypeVnd = new MimeTypeVnd(SubType.ITEM, new ContentMimeTypeVndInfo(EMPTY, CONTENT_MIME_TYPE_VND_TYPE)); 61 | // when 62 | 63 | // then 64 | assertFalse(mimeTypeVnd.isValid()); 65 | } 66 | 67 | public void testIsValid_returns_false_if_mime_type_has_null_or_empty_type() { 68 | // given 69 | mimeTypeVnd = new MimeTypeVnd(SubType.ITEM, new ContentMimeTypeVndInfo(CONTENT_MIME_TYPE_VND_NAME, null)); 70 | // when 71 | 72 | // then 73 | assertFalse(mimeTypeVnd.isValid()); 74 | 75 | // -- 76 | // given 77 | mimeTypeVnd = new MimeTypeVnd(SubType.ITEM, new ContentMimeTypeVndInfo(CONTENT_MIME_TYPE_VND_NAME, EMPTY)); 78 | // when 79 | 80 | // then 81 | assertFalse(mimeTypeVnd.isValid()); 82 | } 83 | 84 | public void testGetMimeTypeString() { 85 | mimeTypeVnd = new MimeTypeVnd(SubType.ITEM, new ContentMimeTypeVndInfo(CONTENT_MIME_TYPE_VND_NAME, CONTENT_MIME_TYPE_VND_TYPE)); 86 | 87 | final String expectedTypeString = SubType.ITEM.toString() + File.separator + ContentMimeTypeVndInfo.VND + ContentMimeTypeVndInfo.VND_SEPARATOR + CONTENT_MIME_TYPE_VND_NAME 88 | + ContentMimeTypeVndInfo.VND_SEPARATOR + CONTENT_MIME_TYPE_VND_TYPE; 89 | 90 | assertEquals(expectedTypeString, mimeTypeVnd.getMimeTypeString()); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/model/Account.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.test.model; 23 | 24 | import android.provider.BaseColumns; 25 | 26 | import com.j256.ormlite.field.DatabaseField; 27 | import com.j256.ormlite.table.DatabaseTable; 28 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 29 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 30 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 31 | 32 | /** 33 | * Did you know ? All annotations and parameters are optionnal ! You just need the @Contract 34 | * @author SNI 35 | */ 36 | @DatabaseTable(tableName = "accounts") 37 | @DefaultContentUri(authority = "com.tojc.ormlite.android.test", path = "accounts") 38 | @DefaultContentMimeTypeVnd(name = "com.tojc.ormlite.android.test.provider", type = "accounts") 39 | public class Account { 40 | 41 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 42 | @DefaultSortOrder 43 | private int id; 44 | 45 | @DatabaseField 46 | private String name; 47 | 48 | public Account() { 49 | // ORMLite needs a no-arg constructor 50 | } 51 | 52 | public Account(String name) { 53 | this.id = 0; 54 | this.name = name; 55 | } 56 | 57 | public int getId() { 58 | return id; 59 | } 60 | 61 | public String getName() { 62 | return name; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/model/Membership.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.test.model; 23 | 24 | import android.provider.BaseColumns; 25 | 26 | import com.j256.ormlite.field.DatabaseField; 27 | import com.j256.ormlite.table.DatabaseTable; 28 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 29 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 30 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 31 | 32 | /** 33 | * Did you know ? All annotations and parameters are optionnal ! You just need the @Contract 34 | * @author SNI 35 | */ 36 | @DatabaseTable(tableName = "membership") 37 | @DefaultContentUri(authority = "com.tojc.ormlite.android.test", path = "membership") 38 | @DefaultContentMimeTypeVnd(name = "com.tojc.ormlite.android.test.provider", type = "membership") 39 | public class Membership { 40 | 41 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 42 | @DefaultSortOrder 43 | private int id; 44 | 45 | @DatabaseField 46 | private int daysOfMembership; 47 | 48 | public Membership() { 49 | // ORMLite needs a no-arg constructor 50 | } 51 | 52 | public Membership(int daysOfMembership) { 53 | this.id = 0; 54 | this.daysOfMembership = daysOfMembership; 55 | } 56 | 57 | public int getId() { 58 | return id; 59 | } 60 | 61 | public int getDaysOfMembership() { 62 | return daysOfMembership; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/AccountContract.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.test.provider; 23 | 24 | import android.content.ContentResolver; 25 | import android.net.Uri; 26 | import android.provider.BaseColumns; 27 | 28 | public final class AccountContract implements BaseColumns { 29 | 30 | private AccountContract() { 31 | // utility constructor 32 | } 33 | 34 | public static final String AUTHORITY = "com.tojc.ormlite.android.test"; 35 | 36 | public static final String CONTENT_URI_PATH = "accounts"; 37 | 38 | public static final String MIMETYPE_TYPE = "accounts"; 39 | public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.test.provider"; 40 | 41 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 42 | 43 | public static final String NAME = "name"; 44 | } 45 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/MembershipContract.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.test.provider; 23 | 24 | import android.content.ContentResolver; 25 | import android.net.Uri; 26 | import android.provider.BaseColumns; 27 | 28 | public final class MembershipContract implements BaseColumns { 29 | 30 | private MembershipContract() { 31 | // utility constructor 32 | } 33 | 34 | public static final String AUTHORITY = "com.tojc.ormlite.android.test"; 35 | 36 | public static final String CONTENT_URI_PATH = "membership"; 37 | 38 | public static final String MIMETYPE_TYPE = "membership"; 39 | public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.test.provider"; 40 | 41 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 42 | 43 | public static final String DAYSOFMEMBERSHIP = "daysofmembership"; 44 | } 45 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/SampleHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.test.provider; 23 | 24 | import java.sql.SQLException; 25 | 26 | import android.content.Context; 27 | import android.database.sqlite.SQLiteDatabase; 28 | 29 | import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; 30 | import com.j256.ormlite.support.ConnectionSource; 31 | import com.j256.ormlite.table.TableUtils; 32 | import com.tojc.ormlite.android.test.model.Account; 33 | import com.tojc.ormlite.android.test.model.Membership; 34 | 35 | public class SampleHelper extends OrmLiteSqliteOpenHelper { 36 | 37 | /* package-private */static final Class[] CLASS_LIST = new Class[] {Account.class, Membership.class}; 38 | 39 | public SampleHelper(Context context) { 40 | super(context, "MyDatabase", null, 1); 41 | } 42 | 43 | @Override 44 | public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { 45 | try { 46 | resetAllTables(); 47 | } catch (SQLException e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | 52 | @Override 53 | public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) { 54 | try { 55 | resetAllTables(); 56 | } catch (SQLException e) { 57 | e.printStackTrace(); 58 | } 59 | } 60 | 61 | public void resetAllTables() throws SQLException { 62 | for (Class clazz : CLASS_LIST) { 63 | TableUtils.dropTable(connectionSource, clazz, true); 64 | TableUtils.createTable(connectionSource, clazz); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /ormlite-content-provider-library-test/src/com/tojc/ormlite/android/test/provider/UnderTestSampleProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.test.provider; 23 | 24 | import com.tojc.ormlite.android.OrmLiteSimpleContentProvider; 25 | import com.tojc.ormlite.android.framework.MatcherController; 26 | import com.tojc.ormlite.android.framework.MimeTypeVnd.SubType; 27 | import com.tojc.ormlite.android.test.model.Account; 28 | import com.tojc.ormlite.android.test.model.Membership; 29 | 30 | public class UnderTestSampleProvider extends OrmLiteSimpleContentProvider { 31 | @Override 32 | protected Class getHelperClass() { 33 | return SampleHelper.class; 34 | } 35 | 36 | @Override 37 | public boolean onCreate() { 38 | int patternCode = 1; 39 | setMatcherController(new MatcherController()// 40 | .add(Account.class, SubType.DIRECTORY, "", patternCode++)// 41 | .add(Account.class, SubType.ITEM, "#", patternCode++)// 42 | .add(Membership.class, SubType.DIRECTORY, "", patternCode++)// 43 | .add(Membership.class, SubType.ITEM, "#", patternCode++)); 44 | return true; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android-library' 2 | 3 | repositories { 4 | mavenCentral() 5 | } 6 | 7 | dependencies { 8 | compile "com.j256.ormlite:ormlite-core:${ormliteVersion}" 9 | compile "com.j256.ormlite:ormlite-android:${ormliteVersion}" 10 | } 11 | 12 | android { 13 | compileSdkVersion androidCompileSdkVersion 14 | buildToolsVersion androidBuildToolsVersion 15 | 16 | buildTypes { 17 | defaultConfig { 18 | minSdkVersion defaultConfigMinSdkVersion 19 | targetSdkVersion defaultConfigTargetSdkVersion 20 | versionCode 1 21 | versionName project.version 22 | } 23 | 24 | debug { 25 | debuggable true 26 | } 27 | release { 28 | debuggable false 29 | } 30 | } 31 | 32 | sourceSets { 33 | main { 34 | manifest.srcFile 'AndroidManifest.xml' 35 | java.srcDirs = ['src'] 36 | resources.srcDirs = ['src'] 37 | aidl.srcDirs = ['src'] 38 | renderscript.srcDirs = ['src'] 39 | res.srcDirs = ['res'] 40 | assets.srcDirs = ['assets'] 41 | } 42 | 43 | // Move the tests to tests/java, tests/res, etc... 44 | //instrumentTest.setRoot('tests') 45 | androidTest.setRoot('tests') 46 | 47 | // Move the build types to build-types/ 48 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 49 | // This moves them out of them default location under src//... which would 50 | // conflict with src/ being used by the main source set. 51 | // Adding new build types or product flavors should be accompanied 52 | // by a similar customization. 53 | debug.setRoot('build-types/debug') 54 | release.setRoot('build-types/release') 55 | } 56 | } 57 | 58 | commonlibrary { 59 | apply project, "addTaskArtifactAar" 60 | apply project, "addTaskArtifactApklib" 61 | apply project, "addTaskArtifactJar" 62 | apply project, "addTaskArtifactJavadocJar" 63 | apply project, "addTaskArtifactSourceJar" 64 | 65 | apply project, "addTaskCodeQualityCheckstyle" 66 | apply project, "addTaskCodeQualityFindbugs" 67 | apply project, "addTaskCodeQualityPmd" 68 | 69 | apply project, "NeutralNexus" 70 | } 71 | 72 | checkstyle { 73 | ignoreFailures = false 74 | showViolations = false 75 | configFile = new File("$rootDir/style_checks.xml") 76 | } 77 | 78 | findbugs { 79 | ignoreFailures = false 80 | effort = "max" 81 | excludeFilter file("$projectDir/findbugs-exclude.xml") 82 | } 83 | 84 | pmd { 85 | ignoreFailures = true 86 | ruleSets = ["android", "basic", "design", "imports", "braces", "strings"] 87 | } 88 | 89 | artifacts { 90 | afterEvaluate { 91 | archives packageArtifactReleaseAar 92 | archives packageArtifactReleaseApklib 93 | archives packageArtifactReleaseJar 94 | archives packageArtifactReleaseSourceJar 95 | archives packageArtifactReleaseJavadocJar 96 | } 97 | } 98 | 99 | apply from: "${rootDir}/pom.gradle" 100 | customizePom { 101 | name = "Android-OrmLiteContentProvider Library" 102 | description = "This is a library that easy to make using ContentProvider with OrmLite." 103 | } 104 | 105 | nexus { 106 | localPublishing = rootProject.ext.localPublishing 107 | } 108 | 109 | ext.javadocLinks = [ 110 | "http://ormlite.com/javadoc/ormlite-core/", 111 | "http://ormlite.com/javadoc/ormlite-android/" 112 | ] as String[] 113 | 114 | // http://www.gradle.org/docs/current/userguide/publishing_maven.html 115 | // http://www.flexlabs.org/2013/06/using-local-aar-android-library-packages-in-gradle-builds 116 | // http://www.rickcarragher.com/blog/2014/01/21/gradle-and-android 117 | 118 | // http://mike-neck.github.io/blog/2013/06/19/publish-maven-artifact-with-sign-files-1/ 119 | // http://mike-neck.github.io/blog/2013/06/21/how-to-publish-artifacts-with-gradle-maven-publish-plugin-version-1-dot-6/ 120 | 121 | // http://chris.banes.me/2013/08/27/pushing-aars-to-maven-central/ 122 | // https://github.com/chrisbanes/gradle-mvn-push/blob/master/gradle-mvn-push.gradle 123 | // http://gmariotti.blogspot.jp/2013/09/publish-aar-file-to-maven-central-with.html 124 | 125 | 126 | 127 | 128 | // https://github.com/hibernate/hibernate-matrix-testing/blob/master/build.gradle 129 | // https://github.com/JakeWharton/hugo/blob/master/hugo-plugin/build.gradle 130 | 131 | // https://github.com/bmuschko/gradle-nexus-plugin/blob/master/src/main/groovy/org/gradle/api/plugins/nexus/NexusPlugin.groovy 132 | // https://github.com/bmuschko/gradle-nexus-plugin/blob/master/src/main/groovy/org/gradle/api/plugins/nexus/NexusPluginExtension.groovy 133 | 134 | // http://gradle.monochromeroad.com/docs/userguide/signing_plugin.html 135 | 136 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/findbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/javadoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.tojc.ormlite.android 7 | ormlite-content-provider-parent 8 | 1.0.4-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | ormlite-content-provider-library 13 | Android-OrmLiteContentProvider Library 14 | apklib 15 | This is a library that easy to make using ContentProvider with OrmLite. 16 | 17 | 18 | 19 | ${project.parent.basedir} 20 | 21 | 22 | 23 | 24 | com.google.android 25 | android 26 | provided 27 | 28 | 29 | com.j256.ormlite 30 | ormlite-core 31 | 32 | 33 | com.j256.ormlite 34 | ormlite-android 35 | 36 | 37 | 38 | 39 | src 40 | test 41 | 42 | 43 | 44 | com.google.code.maven-replacer-plugin 45 | maven-replacer-plugin 46 | 47 | 48 | process-sources 49 | 50 | replace 51 | 52 | 53 | 54 | 55 | true 56 | target/generated-sources/r/com/tojc/ormlite/android/OrmLiteContentProvider/R.java 57 | target/generated-sources/r/com/tojc/ormlite/android/OrmLiteContentProvider/R.java 58 | false 59 | static final int 60 | static int 61 | 62 | 63 | 64 | 65 | com.jayway.maven.plugins.android.generation2 66 | android-maven-plugin 67 | true 68 | 69 | 70 | 71 | org.apache.maven.plugins 72 | maven-source-plugin 73 | 74 | 75 | 76 | 77 | attach-sources 78 | package 79 | 80 | 81 | jar 82 | 83 | 84 | 85 | 86 | 87 | 88 | org.apache.maven.plugins 89 | maven-javadoc-plugin 90 | 91 | true 92 | 93 | 94 | 95 | attach-javadoc 96 | package 97 | 98 | jar 99 | 100 | 101 | 102 | 103 | 104 | 105 | org.codehaus.mojo 106 | build-helper-maven-plugin 107 | 108 | 109 | package 110 | 111 | attach-artifact 112 | 113 | 114 | 115 | 116 | jar 117 | ${project.build.directory}/${project.build.finalName}.jar 118 | 119 | 120 | aar 121 | ${project.basedir}/build/libs/${project.artifactId}.aar 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | org.apache.maven.plugins 131 | maven-checkstyle-plugin 132 | 133 | 134 | 135 | org.codehaus.mojo 136 | findbugs-maven-plugin 137 | 138 | ${project.basedir}/findbugs-exclude.xml 139 | 140 | 141 | 142 | org.apache.maven.plugins 143 | maven-pmd-plugin 144 | 145 | 146 | ${basedir}/target/generated-sources/r/ 147 | 148 | 149 | 150 | 151 | maven-compiler-plugin 152 | 153 | 154 | 155 | 156 | 157 | 158 | lint 159 | 160 | 161 | 162 | com.lewisd 163 | lint-maven-plugin 164 | 0.0.6 165 | 166 | 167 | validate 168 | 169 | check 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-18 15 | android.library=true 16 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/res/values/dummy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/OrmLiteBaseContentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android; 23 | 24 | import com.j256.ormlite.android.apptools.OpenHelperManager; 25 | import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; 26 | import com.j256.ormlite.logger.Logger; 27 | import com.j256.ormlite.logger.LoggerFactory; 28 | import com.j256.ormlite.support.ConnectionSource; 29 | 30 | import android.content.ContentProvider; 31 | 32 | /** 33 | * Base class to use for ContentProvider in Android. Like OrmLiteBaseActivity, this class is a thin 34 | * wrapper. 35 | * @see com.j256.ormlite.android.apptools.OrmLiteBaseActivity 36 | * @author Jaken 37 | */ 38 | public abstract class OrmLiteBaseContentProvider extends ContentProvider { 39 | private static Logger logger = LoggerFactory.getLogger(OrmLiteBaseContentProvider.class); 40 | 41 | private volatile T helper = null; 42 | private volatile boolean destroyed = false; 43 | 44 | protected abstract Class getHelperClass(); 45 | 46 | /** 47 | * Get a helper for this action. If you need to override, please consider createHelper(). 48 | * @see com.tojc.ormlite.android.OrmLiteBaseContentProvider#createHelper() 49 | * @return Return an instance of the helper. 50 | */ 51 | public T getHelper() { 52 | if (this.helper == null) { 53 | if (this.destroyed) { 54 | throw new IllegalStateException("A call to shutdown has already been made and the helper cannot be used after that point"); 55 | } 56 | this.helper = this.createHelper(); 57 | logger.trace("{}: got new helper {} from OpenHelperManager", this, this.helper); 58 | } 59 | return this.helper; 60 | } 61 | 62 | /** 63 | * Create the Helper object. If you want to change function, please override this method. 64 | * @see com.tojc.ormlite.android.OrmLiteBaseContentProvider#releaseHelper() 65 | * @return Return an instance of the helper. 66 | */ 67 | protected T createHelper() { 68 | return OpenHelperManager.getHelper(this.getContext(), this.getHelperClass()); 69 | } 70 | 71 | /** 72 | * Release the Helper object. If you want to change function, please override this method. 73 | * @see com.tojc.ormlite.android.OrmLiteBaseContentProvider#createHelper() 74 | */ 75 | protected void releaseHelper() { 76 | OpenHelperManager.releaseHelper(); 77 | } 78 | 79 | /** 80 | * Get a connection source for this action. 81 | * @see com.j256.ormlite.support.ConnectionSource 82 | * @return Return an instance of the ConnectionSource. 83 | */ 84 | public ConnectionSource getConnectionSource() { 85 | return getHelper().getConnectionSource(); 86 | } 87 | 88 | @Override 89 | public void shutdown() { 90 | super.shutdown(); 91 | if (this.helper != null) { 92 | this.helper.close(); 93 | this.helper = null; 94 | this.releaseHelper(); 95 | logger.trace("{}: helper {} was released, set to null", this, this.helper); 96 | this.destroyed = true; 97 | } 98 | } 99 | 100 | @Override 101 | public String toString() { 102 | return getClass().getSimpleName() + "@" + Integer.toHexString(super.hashCode()); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/AdditionalAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation; 23 | 24 | import java.lang.annotation.ElementType; 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.RetentionPolicy; 27 | import java.lang.annotation.Target; 28 | 29 | /** 30 | * It is the annotations that are added in OrmLiteContentProvider library. It is 31 | * also a class to manage their information. 32 | * @author Jaken 33 | */ 34 | public class AdditionalAnnotation { 35 | /** 36 | * This specifies the default ContentUri. If you do not want to use the 37 | * DefaultContentUri annotation, you must call the 38 | * MatcherPattern#setContentUri(). "content://authority/path" 39 | * @see com.tojc.ormlite.android.framework.MatcherPattern#setContentUri(String, 40 | * String) 41 | * @author Jaken 42 | */ 43 | @Retention(RetentionPolicy.SOURCE) 44 | @Target({ ElementType.TYPE }) 45 | public @interface Contract { 46 | String contractClassName() default ""; 47 | } 48 | 49 | /** 50 | * This specifies the default ContentUri. If you do not want to use the 51 | * DefaultContentUri annotation, you must call the 52 | * MatcherPattern#setContentUri(). "content://authority/path" 53 | * @see com.tojc.ormlite.android.framework.MatcherPattern#setContentUri(String, 54 | * String) 55 | * @author Jaken 56 | */ 57 | @Retention(RetentionPolicy.RUNTIME) 58 | @Target({ ElementType.TYPE }) 59 | public @interface DefaultContentUri { 60 | String authority() default ""; 61 | 62 | String path() default ""; 63 | } 64 | 65 | /** 66 | * This specifies the default MIME types(Provider-specific part only and vnd 67 | * only). If you do not want to use the DefaultContentMimeTypeVnd 68 | * annotation, you must call the MatcherPattern#setContentMimeTypeVnd(). 69 | * Provider-specific part: "vnd.name.type" 70 | * @see com.tojc.ormlite.android.framework.MatcherPattern#setContentMimeTypeVnd(String, 71 | * String) 72 | * @author Jaken 73 | */ 74 | @Retention(RetentionPolicy.RUNTIME) 75 | @Target({ ElementType.TYPE }) 76 | public @interface DefaultContentMimeTypeVnd { 77 | String name() default ""; 78 | 79 | String type() default ""; 80 | } 81 | 82 | /** 83 | * Be used query method, if you do not specify how to sort. DefaultSortOrder 84 | * annotation can be used in more than one field. In that case, specify the 85 | * sort in ascending order of weight. If you omit the order, it will be in 86 | * ascending order by default. If you specify the SortOrder.ASC, which 87 | * explicitly grants the ASC. 88 | * @author Jaken 89 | */ 90 | @Retention(RetentionPolicy.RUNTIME) 91 | @Target({ ElementType.FIELD }) 92 | public @interface DefaultSortOrder { 93 | SortOrder order() default SortOrder.DEFAULT; 94 | 95 | int weight() default 0; 96 | } 97 | 98 | /** 99 | * If you want to replace the column name, then you use the ProjectionMap 100 | * annotation. You do not need to use it normally. Fields that do not 101 | * specify a ProjectionMap annotation, set the default column name. If you 102 | * take advantage of ProjectionMap annotation, use the following in 103 | * onQuery().
104 | * ex)
105 | * 106 | * SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
107 | * builder.setProjectionMap(target.getTableInfo().getProjectionMap());
108 | *
109 | * @author Jaken 110 | */ 111 | @Retention(RetentionPolicy.RUNTIME) 112 | @Target({ ElementType.FIELD }) 113 | public @interface ProjectionMap { 114 | String value(); 115 | } 116 | 117 | /** 118 | * Represents the SortOrder. 119 | * @author Jaken 120 | */ 121 | public enum SortOrder { 122 | /** 123 | * Are treated the same as ASC. (dependent SQLite) 124 | */ 125 | DEFAULT { 126 | @Override 127 | public String toString() { 128 | return ""; 129 | } 130 | }, 131 | 132 | /** 133 | * Explicitly specify the ASC. 134 | */ 135 | ASC, 136 | 137 | /** 138 | * Explicitly specify the DESC. 139 | */ 140 | DESC; 141 | 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/OrmLiteAnnotationAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation; 23 | 24 | import java.lang.reflect.AnnotatedElement; 25 | import java.lang.reflect.Field; 26 | 27 | import android.text.TextUtils; 28 | 29 | import com.j256.ormlite.field.DatabaseField; 30 | import com.j256.ormlite.table.DatabaseTableConfig; 31 | 32 | /** 33 | * Class to access the standard OrmLite annotation. 34 | * @author Jaken 35 | */ 36 | public final class OrmLiteAnnotationAccessor { 37 | 38 | private OrmLiteAnnotationAccessor() { 39 | // utility constructor 40 | } 41 | 42 | /** 43 | * Gets the table name from DatabaseTable annotation. If the DatabaseTable#tableName is not 44 | * specified, returns the class name. 45 | * @param element 46 | * Element to be evaluated. 47 | * @return Returns the table name. 48 | */ 49 | public static String getAnnotationTableName(AnnotatedElement element) { 50 | String result = ""; 51 | result = DatabaseTableConfig.extractTableName((Class) element); 52 | return result; 53 | } 54 | 55 | /** 56 | * Gets the column name from DatabaseField annotation. If the DatabaseField#columnName is not 57 | * specified, returns the field name. 58 | * @param element 59 | * Element to be evaluated. 60 | * @return Returns the column name. 61 | */ 62 | public static String getAnnotationColumnName(AnnotatedElement element) { 63 | String result = ""; 64 | DatabaseField databaseField = element.getAnnotation(DatabaseField.class); 65 | if (databaseField != null) { 66 | result = databaseField.columnName(); 67 | if (TextUtils.isEmpty(result)) { 68 | result = ((Field) element).getName(); 69 | } 70 | } 71 | return result; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/AnnotationInfoBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation.info; 23 | 24 | import com.tojc.ormlite.android.framework.Validity; 25 | 26 | /** 27 | * Base class that manages the annotation information. 28 | * @author Jaken 29 | */ 30 | public abstract class AnnotationInfoBase implements Validity { 31 | private boolean validFlag = false; 32 | 33 | public AnnotationInfoBase() { 34 | validFlagOff(); 35 | } 36 | 37 | protected void validFlagOn() { 38 | this.validFlag = true; 39 | } 40 | 41 | protected void validFlagOff() { 42 | this.validFlag = false; 43 | } 44 | 45 | protected abstract boolean isValidValue(); 46 | 47 | @Override 48 | public boolean isValid() { 49 | return this.validFlag && isValidValue(); 50 | } 51 | 52 | @Override 53 | public boolean isValid(boolean throwException) { 54 | boolean result = this.isValid(); 55 | String message = this.getClass().getSimpleName() + " class status is abnormal."; 56 | thowIllegalStateExceptionUnderCondition(throwException && !result, message); 57 | return result; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "AnnotationInfoBase{" 63 | + "validFlag=" + validFlag 64 | + "} " + super.toString(); 65 | } 66 | 67 | protected final void thowIllegalStateExceptionUnderCondition(boolean condition, String message) { 68 | if (condition) { 69 | throw new IllegalStateException(message); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentMimeTypeVndInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation.info; 23 | 24 | import java.lang.reflect.AnnotatedElement; 25 | 26 | import android.text.TextUtils; 27 | 28 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 29 | 30 | /** 31 | * Manage the MIME Types information. 32 | * @author Jaken 33 | */ 34 | public class ContentMimeTypeVndInfo extends AnnotationInfoBase { 35 | // ---------------------------------- 36 | // CONSTANTS 37 | // ---------------------------------- 38 | public static final String VND = "vnd"; 39 | public static final String PROVIDER_SUFFIX = ".provider"; 40 | public static final String VND_SEPARATOR = "."; 41 | 42 | // ---------------------------------- 43 | // ATRRIBUTES 44 | // ---------------------------------- 45 | private String name; 46 | private String type; 47 | 48 | // ---------------------------------- 49 | // CONSTRUCTORS 50 | // ---------------------------------- 51 | 52 | public ContentMimeTypeVndInfo(AnnotatedElement element) { 53 | DefaultContentMimeTypeVnd contentMimeTypeVnd = element.getAnnotation(DefaultContentMimeTypeVnd.class); 54 | String name = null; 55 | String type = null; 56 | if (contentMimeTypeVnd != null) { 57 | name = contentMimeTypeVnd.name(); 58 | type = contentMimeTypeVnd.type(); 59 | } 60 | 61 | if (element instanceof Class) { 62 | Class clazz = (Class) element; 63 | if (TextUtils.isEmpty(name)) { 64 | name = clazz.getPackage().getName() + PROVIDER_SUFFIX; 65 | } 66 | 67 | if (TextUtils.isEmpty(type)) { 68 | type = clazz.getSimpleName().toLowerCase(); 69 | } 70 | } 71 | 72 | initialize(name, type); 73 | } 74 | 75 | public ContentMimeTypeVndInfo(String name, String type) { 76 | initialize(name, type); 77 | } 78 | 79 | // ---------------------------------- 80 | // PUBLIC METHODS 81 | // ---------------------------------- 82 | public String getName() { 83 | return this.name; 84 | } 85 | 86 | public String getType() { 87 | return this.type; 88 | } 89 | 90 | public String getVndProviderSpecificString() { 91 | return VND + VND_SEPARATOR + this.name + VND_SEPARATOR + this.type; 92 | } 93 | 94 | @Override 95 | protected boolean isValidValue() { 96 | return !TextUtils.isEmpty(this.name) && !TextUtils.isEmpty(this.type); 97 | } 98 | 99 | // ---------------------------------- 100 | // PRIVATE METHODS 101 | // ---------------------------------- 102 | private void initialize(String name, String type) { 103 | this.name = name; 104 | this.type = type; 105 | validFlagOn(); 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return "ContentMimeTypeVndInfo{" 111 | + "name='" + name + '\'' 112 | + ", type='" + type + '\'' 113 | + "} " + super.toString(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ContentUriInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation.info; 23 | 24 | import java.lang.reflect.AnnotatedElement; 25 | 26 | import android.text.TextUtils; 27 | 28 | import android.content.ContentResolver; 29 | import android.net.Uri; 30 | 31 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 32 | 33 | /** 34 | * Manage the ContentUri information. 35 | * @author Jaken 36 | */ 37 | public class ContentUriInfo extends AnnotationInfoBase { 38 | // ---------------------------------- 39 | // ATTRIBUTES 40 | // ---------------------------------- 41 | private String authority; 42 | private String path; 43 | 44 | // ---------------------------------- 45 | // CONSTRUCTORS 46 | // ---------------------------------- 47 | public ContentUriInfo(AnnotatedElement element) { 48 | DefaultContentUri contentUri = element.getAnnotation(DefaultContentUri.class); 49 | String authority = null; 50 | String path = null; 51 | if (contentUri != null) { 52 | authority = contentUri.authority(); 53 | path = contentUri.path(); 54 | } 55 | 56 | if (element instanceof Class) { 57 | Class clazz = (Class) element; 58 | if (TextUtils.isEmpty(authority)) { 59 | authority = clazz.getPackage().getName(); 60 | } 61 | if (TextUtils.isEmpty(path)) { 62 | // TODO use DataBase annotation 63 | path = clazz.getSimpleName().toLowerCase(); 64 | } 65 | } 66 | 67 | initialize(authority, path); 68 | } 69 | 70 | public ContentUriInfo(String authority, String path) { 71 | initialize(authority, path); 72 | } 73 | 74 | // ---------------------------------- 75 | // PUBLIC METHODS 76 | // ---------------------------------- 77 | public String getAuthority() { 78 | return this.authority; 79 | } 80 | 81 | public String getPath() { 82 | return this.path; 83 | } 84 | 85 | public Uri getContentUri() { 86 | return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(this.authority).appendPath(this.path).build(); 87 | } 88 | 89 | @Override 90 | protected boolean isValidValue() { 91 | return !TextUtils.isEmpty(this.authority) && !TextUtils.isEmpty(this.path); 92 | } 93 | 94 | // ---------------------------------- 95 | // PRIVATE METHODS 96 | // ---------------------------------- 97 | private void initialize(String authority, String path) { 98 | this.authority = authority; 99 | this.path = path; 100 | validFlagOn(); 101 | } 102 | 103 | @Override 104 | public String toString() { 105 | return "ContentUriInfo{" 106 | + "authority='" + authority + '\'' 107 | + ", path='" + path + '\'' 108 | + "} " + super.toString(); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/ProjectionMapInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation.info; 23 | 24 | import java.lang.reflect.AnnotatedElement; 25 | 26 | import android.text.TextUtils; 27 | 28 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.ProjectionMap; 29 | 30 | /** 31 | * Manage the ProjectionMap information. 32 | * @author Jaken 33 | */ 34 | public class ProjectionMapInfo extends AnnotationInfoBase { 35 | private String name; 36 | 37 | public ProjectionMapInfo(AnnotatedElement element) { 38 | ProjectionMap projectionMap = element.getAnnotation(ProjectionMap.class); 39 | if (projectionMap != null) { 40 | this.name = projectionMap.value(); 41 | validFlagOn(); 42 | } 43 | } 44 | 45 | public ProjectionMapInfo(String name) { 46 | this.name = name; 47 | validFlagOn(); 48 | } 49 | 50 | public String getName() { 51 | return this.name; 52 | } 53 | 54 | @Override 55 | protected boolean isValidValue() { 56 | return !TextUtils.isEmpty(name); 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "ProjectionMapInfo{" 62 | + "name='" + name + '\'' 63 | + "} " + super.toString(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/annotation/info/SortOrderInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.annotation.info; 23 | 24 | import java.lang.reflect.AnnotatedElement; 25 | 26 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 27 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.SortOrder; 28 | 29 | /** 30 | * Manage the SortOrder information. 31 | * @author Jaken 32 | */ 33 | public class SortOrderInfo extends AnnotationInfoBase { 34 | private static final String SQL_ORDER_SEPARATOR = " "; 35 | 36 | private SortOrder order; 37 | private int weight; 38 | 39 | public SortOrderInfo(AnnotatedElement element) { 40 | DefaultSortOrder defaultSortOrder = element.getAnnotation(DefaultSortOrder.class); 41 | if (defaultSortOrder != null) { 42 | this.order = defaultSortOrder.order(); 43 | this.weight = defaultSortOrder.weight(); 44 | validFlagOn(); 45 | } 46 | } 47 | 48 | public SortOrderInfo(SortOrder order, int weight) { 49 | this.order = order; 50 | this.weight = weight; 51 | validFlagOn(); 52 | } 53 | 54 | public SortOrder getOrder() { 55 | return this.order; 56 | } 57 | 58 | public int getWeight() { 59 | return this.weight; 60 | } 61 | 62 | public String makeSqlOrderString(String fieldname) { 63 | StringBuilder result = new StringBuilder(); 64 | result.append(fieldname); 65 | result.append(SQL_ORDER_SEPARATOR); 66 | result.append(this.order.toString()); 67 | return result.toString().trim(); 68 | } 69 | 70 | @Override 71 | protected boolean isValidValue() { 72 | return true; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return "SortOrderInfo{" 78 | + "order=" + order 79 | + ", weight=" + weight 80 | + "} " + super.toString(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/ColumnInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.framework; 23 | 24 | import java.lang.reflect.Field; 25 | 26 | import com.j256.ormlite.field.DatabaseField; 27 | import com.tojc.ormlite.android.annotation.OrmLiteAnnotationAccessor; 28 | import com.tojc.ormlite.android.annotation.info.ProjectionMapInfo; 29 | import com.tojc.ormlite.android.annotation.info.SortOrderInfo; 30 | 31 | /** 32 | * Manage the database column information. 33 | * @author Jaken 34 | */ 35 | public class ColumnInfo implements Validity { 36 | private Field field; 37 | private String columnName; 38 | private SortOrderInfo defaultSortOrderInfo; 39 | private ProjectionMapInfo projectionMapInfo; 40 | 41 | public ColumnInfo(Field columnField) { 42 | if (!columnField.isAnnotationPresent(DatabaseField.class)) { 43 | throw new IllegalArgumentException("Parameter does not implement the DatabaseField annotation."); 44 | } 45 | 46 | this.field = columnField; 47 | this.columnName = OrmLiteAnnotationAccessor.getAnnotationColumnName(columnField); 48 | this.defaultSortOrderInfo = new SortOrderInfo(columnField); 49 | this.projectionMapInfo = new ProjectionMapInfo(columnField); 50 | } 51 | 52 | @Override 53 | public boolean isValid() { 54 | return isValid(false); 55 | } 56 | 57 | @Override 58 | public boolean isValid(boolean throwException) { 59 | boolean result = true; 60 | 61 | // none of this can happen, keep for a while : May 18th 2013 62 | // TODO remove if useless 63 | // if (this.field == null) { 64 | // result = false; 65 | // if (throwException && !result) { 66 | // throw new IllegalStateException("field is null."); 67 | // } 68 | // } else if (StringUtils.isEmpty(columnName)) { 69 | // result = false; 70 | // if (throwException && !result) { 71 | // throw new IllegalStateException("columnName is zero string."); 72 | // } 73 | // } 74 | // Acceptable 75 | // else if(!this.defaultSortOrderInfo.isValid()) 76 | // { 77 | // result = false; 78 | // } 79 | // Acceptable 80 | // else if(!this.projectionMapInfo.isValid()) 81 | // { 82 | // result = false; 83 | // } 84 | return result; 85 | } 86 | 87 | public Field getField() { 88 | return this.field; 89 | } 90 | 91 | public String getColumnName() { 92 | return this.columnName; 93 | } 94 | 95 | public String getProjectionColumnName() { 96 | String result = this.columnName; 97 | if (this.projectionMapInfo.isValid()) { 98 | result = this.projectionMapInfo.getName(); 99 | } 100 | return result; 101 | } 102 | 103 | /** 104 | * @see com.tojc.ormlite.android.framework.TableInfo#getDefaultSortOrderString() 105 | * @return Gets the default value that is specified in the annotation. This 106 | * represents the state of this column only. If you want to know 107 | * about the table sort order, you refer to the 108 | * TableInfo#getDefaultSortOrderString(). 109 | */ 110 | public SortOrderInfo getDefaultSortOrderInfo() { 111 | return this.defaultSortOrderInfo; 112 | } 113 | 114 | /** 115 | * @see com.tojc.ormlite.android.framework.TableInfo#getProjectionMap() 116 | * @return Gets the default value that is specified in the annotation. This 117 | * represents the state of this column only. If you want to know 118 | * about the table ProjectionMap, you refer to the 119 | * TableInfo#getProjectionMap() 120 | */ 121 | public ProjectionMapInfo getProjectionMapInfo() { 122 | return this.projectionMapInfo; 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/MimeTypeVnd.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.framework; 23 | 24 | import java.io.File; 25 | 26 | import android.content.ContentResolver; 27 | 28 | import com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo; 29 | 30 | /** 31 | * Manage the MIME types information. It provides full support for ContentProvider MIME Types. 32 | * vnd.android.cursor.dir/vnd.com.example.provider.table1 33 | * vnd.android.cursor.item/vnd.com.example.provider.table1 Type part : vnd Subtype part : If the URI 34 | * pattern is for a single row: android.cursor.item/ If the URI pattern is for more than one row: 35 | * android.cursor.dir/ Provider-specific part: vnd.name.type (Manage the ContentMimeTypeVndInfo 36 | * class) 37 | * @see com.tojc.ormlite.android.framework.MimeTypeVnd.SubType 38 | * @see com.tojc.ormlite.android.annotation.info.ContentMimeTypeVndInfo 39 | * @author Jaken 40 | */ 41 | public class MimeTypeVnd implements Validity { 42 | public enum SubType { 43 | ITEM(ContentResolver.CURSOR_ITEM_BASE_TYPE), // 44 | DIRECTORY(ContentResolver.CURSOR_DIR_BASE_TYPE); 45 | 46 | private SubType(String name) { 47 | this.name = name; 48 | } 49 | 50 | private final String name; 51 | 52 | @Override 53 | public String toString() { 54 | return this.name; 55 | } 56 | } 57 | 58 | private SubType subType; 59 | private ContentMimeTypeVndInfo providerSpecific; 60 | 61 | public MimeTypeVnd(SubType subType, ContentMimeTypeVndInfo providerSpecific) { 62 | this.subType = subType; 63 | this.providerSpecific = providerSpecific; 64 | } 65 | 66 | @Override 67 | public boolean isValid() { 68 | return isValid(false); 69 | } 70 | 71 | @Override 72 | public boolean isValid(boolean throwException) { 73 | boolean result = true; 74 | 75 | if (this.subType == null) { 76 | result = false; 77 | if (throwException && !result) { 78 | throw new IllegalStateException("subType is null."); 79 | } 80 | } else if (!this.providerSpecific.isValid()) { 81 | result = false; 82 | if (throwException && !result) { 83 | throw new IllegalStateException("providerSpecific is invalid."); 84 | } 85 | } 86 | return result; 87 | } 88 | 89 | public SubType getSubType() { 90 | return this.subType; 91 | } 92 | 93 | public void setSubType(SubType subType) { 94 | this.subType = subType; 95 | } 96 | 97 | public ContentMimeTypeVndInfo getProviderSpecific() { 98 | return this.providerSpecific; 99 | } 100 | 101 | public void setProviderSpecific(ContentMimeTypeVndInfo providerSpecific) { 102 | this.providerSpecific = providerSpecific; 103 | } 104 | 105 | public String getMimeTypeString() { 106 | return this.subType.toString() + File.separator + this.providerSpecific.getVndProviderSpecificString(); 107 | } 108 | 109 | @Override 110 | public String toString() { 111 | return getMimeTypeString(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/OperationParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.framework; 23 | 24 | import android.content.ContentValues; 25 | import android.net.Uri; 26 | 27 | /** 28 | * This keeps the parameters of Operation. Through the interface and exposes 29 | * only the methods required for event. 30 | * @author Jaken 31 | */ 32 | public class OperationParameters { 33 | public interface OperationParametersBaseInterface { 34 | Uri getUri(); 35 | } 36 | 37 | public interface QueryParameters extends OperationParametersBaseInterface { 38 | String[] getProjection(); 39 | 40 | String getSelection(); 41 | 42 | String[] getSelectionArgs(); 43 | 44 | String getSortOrder(); 45 | } 46 | 47 | public interface InsertParameters extends OperationParametersBaseInterface { 48 | ContentValues getValues(); 49 | } 50 | 51 | public interface DeleteParameters extends OperationParametersBaseInterface { 52 | String getSelection(); 53 | 54 | String[] getSelectionArgs(); 55 | } 56 | 57 | public interface UpdateParameters extends OperationParametersBaseInterface { 58 | ContentValues getValues(); 59 | 60 | String getSelection(); 61 | 62 | String[] getSelectionArgs(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/Parameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.framework; 23 | 24 | import android.content.ContentValues; 25 | import android.net.Uri; 26 | 27 | import com.tojc.ormlite.android.framework.OperationParameters.DeleteParameters; 28 | import com.tojc.ormlite.android.framework.OperationParameters.InsertParameters; 29 | import com.tojc.ormlite.android.framework.OperationParameters.OperationParametersBaseInterface; 30 | import com.tojc.ormlite.android.framework.OperationParameters.QueryParameters; 31 | import com.tojc.ormlite.android.framework.OperationParameters.UpdateParameters; 32 | 33 | /** 34 | * Implementation class that holds the parameter. 35 | * @author Jaken 36 | */ 37 | public class Parameter implements OperationParametersBaseInterface, QueryParameters, InsertParameters, 38 | DeleteParameters, UpdateParameters { 39 | // Android Event ITEM 40 | private Uri uri; 41 | private String[] projection; 42 | private String selection; 43 | private String[] selectionArgs; 44 | private String sortOrder; 45 | private ContentValues values; 46 | 47 | public Parameter() { 48 | this.clear(); 49 | } 50 | 51 | public void clear() { 52 | this.uri = null; 53 | this.projection = null; 54 | this.selection = null; 55 | this.selectionArgs = null; 56 | this.sortOrder = null; 57 | this.values = null; 58 | } 59 | 60 | // query 61 | public Parameter(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { 62 | this.clear(); 63 | this.uri = uri; 64 | if (projection != null) { 65 | this.projection = projection.clone(); 66 | } 67 | this.selection = selection; 68 | if (selectionArgs != null) { 69 | this.selectionArgs = selectionArgs.clone(); 70 | } 71 | this.sortOrder = sortOrder; 72 | } 73 | 74 | // insert 75 | public Parameter(Uri uri, ContentValues values) { 76 | this.clear(); 77 | this.uri = uri; 78 | this.values = values; 79 | } 80 | 81 | // delete 82 | public Parameter(Uri uri, String selection, String[] selectionArgs) { 83 | this.clear(); 84 | this.uri = uri; 85 | this.selection = selection; 86 | if (selectionArgs != null) { 87 | this.selectionArgs = selectionArgs.clone(); 88 | } 89 | } 90 | 91 | // update 92 | public Parameter(Uri uri, ContentValues values, String selection, String[] selectionArgs) { 93 | this.clear(); 94 | this.uri = uri; 95 | this.values = values; 96 | this.selection = selection; 97 | if (selectionArgs != null) { 98 | this.selectionArgs = selectionArgs.clone(); 99 | } 100 | } 101 | 102 | @Override 103 | public Uri getUri() { 104 | return this.uri; 105 | } 106 | 107 | public void setUri(Uri uri) { 108 | this.uri = uri; 109 | } 110 | 111 | @Override 112 | public String[] getProjection() { 113 | if (projection == null) { 114 | return null; 115 | } 116 | return this.projection.clone(); 117 | } 118 | 119 | public void setProjection(String[] projection) { 120 | if (projection == null) { 121 | this.projection = null; 122 | } else { 123 | this.projection = projection.clone(); 124 | } 125 | } 126 | 127 | @Override 128 | public String getSelection() { 129 | return this.selection; 130 | } 131 | 132 | public void setSelection(String selection) { 133 | this.selection = selection; 134 | } 135 | 136 | @Override 137 | public String[] getSelectionArgs() { 138 | if (this.selectionArgs != null) { 139 | return this.selectionArgs.clone(); 140 | } else { 141 | return null; 142 | } 143 | } 144 | 145 | public void setSelectionArgs(String[] selectionArgs) { 146 | if (selectionArgs == null) { 147 | this.selectionArgs = null; 148 | } else { 149 | this.selectionArgs = selectionArgs.clone(); 150 | } 151 | } 152 | 153 | @Override 154 | public String getSortOrder() { 155 | return this.sortOrder; 156 | } 157 | 158 | public void setSortOrder(String sortOrder) { 159 | this.sortOrder = sortOrder; 160 | } 161 | 162 | @Override 163 | public ContentValues getValues() { 164 | return this.values; 165 | } 166 | 167 | public void setValues(ContentValues values) { 168 | this.values = values; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/src/com/tojc/ormlite/android/framework/Validity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.framework; 23 | 24 | public interface Validity { 25 | boolean isValid(); 26 | 27 | boolean isValid(boolean throwException); 28 | } 29 | -------------------------------------------------------------------------------- /ormlite-content-provider-library/test/java/dummy.txt: -------------------------------------------------------------------------------- 1 | Empty file so that git save the folder in its tree. 2 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | evaluationDependsOn(':ormlite-content-provider-library') 4 | 5 | repositories{ 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | compile project(':ormlite-content-provider-library') 11 | } 12 | 13 | android { 14 | compileSdkVersion androidCompileSdkVersion 15 | buildToolsVersion androidBuildToolsVersion 16 | 17 | buildTypes { 18 | defaultConfig { 19 | minSdkVersion defaultConfigMinSdkVersion 20 | targetSdkVersion defaultConfigTargetSdkVersion 21 | versionCode 1 22 | versionName project.version 23 | } 24 | 25 | debug { 26 | debuggable true 27 | } 28 | release { 29 | debuggable false 30 | } 31 | } 32 | 33 | sourceSets { 34 | main { 35 | manifest.srcFile 'AndroidManifest.xml' 36 | java.srcDirs = ['src'] 37 | resources.srcDirs = ['src'] 38 | aidl.srcDirs = ['src'] 39 | renderscript.srcDirs = ['src'] 40 | res.srcDirs = ['res'] 41 | assets.srcDirs = ['assets'] 42 | } 43 | 44 | // Move the tests to tests/java, tests/res, etc... 45 | //instrumentTest.setRoot('tests') 46 | androidTest.setRoot('tests') 47 | 48 | // Move the build types to build-types/ 49 | // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 50 | // This moves them out of them default location under src//... which would 51 | // conflict with src/ being used by the main source set. 52 | // Adding new build types or product flavors should be accompanied 53 | // by a similar customization. 54 | debug.setRoot('build-types/debug') 55 | release.setRoot('build-types/release') 56 | } 57 | } 58 | 59 | commonlibrary { 60 | apply project, "addTaskArtifactApk" 61 | apply project, "addTaskArtifactJavadocJar" 62 | apply project, "addTaskArtifactSourceJar" 63 | 64 | apply project, "addTaskCodeQualityCheckstyle" 65 | apply project, "addTaskCodeQualityFindbugs" 66 | apply project, "addTaskCodeQualityPmd" 67 | 68 | apply project, "NeutralNexus" 69 | } 70 | 71 | checkstyle { 72 | ignoreFailures = true 73 | showViolations = false 74 | configFile = new File("$rootDir/style_checks.xml") 75 | } 76 | 77 | findbugs { 78 | ignoreFailures = true 79 | effort = "max" 80 | excludeFilter file("$projectDir/findbugs-exclude.xml") 81 | } 82 | 83 | pmd { 84 | ignoreFailures = true 85 | ruleSets = ["android", "basic", "design", "imports", "braces", "strings"] 86 | } 87 | 88 | artifacts { 89 | afterEvaluate { 90 | archives packageArtifactReleaseApk 91 | archives packageArtifactReleaseSourceJar 92 | archives packageArtifactReleaseJavadocJar 93 | } 94 | } 95 | 96 | apply from: "${rootDir}/pom.gradle" 97 | customizePom { 98 | name = "Android-OrmLiteContentProvider Sample" 99 | description = "This is a project for OrmLiteContentProvider Library sample." 100 | } 101 | 102 | nexus { 103 | localPublishing = rootProject.ext.localPublishing 104 | } 105 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/findbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-sample/ic_launcher-web.png -------------------------------------------------------------------------------- /ormlite-content-provider-sample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.tojc.ormlite.android 7 | ormlite-content-provider-parent 8 | 1.0.4-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | ormlite-content-provider-sample 13 | Android-OrmLiteContentProvider Sample 14 | apk 15 | 16 | 17 | 18 | ${project.parent.basedir} 19 | 20 | 21 | 22 | 23 | com.google.android 24 | android 25 | provided 26 | 27 | 28 | com.google.android 29 | support-v4 30 | provided 31 | 32 | 33 | ${project.groupId} 34 | ormlite-content-provider-library 35 | ${project.version} 36 | apklib 37 | 38 | 39 | 40 | 41 | src/ 42 | 43 | 44 | 45 | com.google.code.maven-replacer-plugin 46 | maven-replacer-plugin 47 | 48 | 49 | process-sources 50 | 51 | replace 52 | 53 | 54 | 55 | 56 | false 57 | target/generated-sources/r/com/tojc/ormlite/android/ormlitecontentprovider/sample/R.java 58 | target/generated-sources/r/com/tojc/ormlite/android/ormlitecontentprovider/sample/R.java 59 | false 60 | static final int 61 | static int 62 | 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-checkstyle-plugin 68 | 69 | 70 | org.apache.maven.plugins 71 | maven-pmd-plugin 72 | 73 | 74 | ${basedir}/target/generated-sources/r/ 75 | 76 | 77 | 78 | 79 | true 80 | com.jayway.maven.plugins.android.generation2 81 | android-maven-plugin 82 | 83 | 84 | maven-compiler-plugin 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-18 15 | android.library.reference.1=../ormlite-content-provider-library 16 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-sample/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-sample/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-sample/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakenjarvis/Android-OrmLiteContentProvider/8f102f0743b308c9f58d43639e98f832fd951985/ormlite-content-provider-sample/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/menu/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OrmLiteContentProviderSample 5 | Hello world! 6 | Settings 7 | 8 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.sample; 23 | 24 | import java.util.ArrayList; 25 | 26 | import android.app.Activity; 27 | import android.content.ContentProviderClient; 28 | import android.content.ContentProviderOperation; 29 | import android.content.ContentValues; 30 | import android.database.Cursor; 31 | import android.os.Bundle; 32 | import android.os.RemoteException; 33 | import android.util.Log; 34 | import android.view.Menu; 35 | 36 | import com.tojc.ormlite.android.ormlitecontentprovider.sample.provider.AccountContract; 37 | 38 | public class MainActivity extends Activity { 39 | private static final int TEST_ENTRY_COUNT = 10; 40 | 41 | @Override 42 | protected void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_main); 45 | 46 | // insert test 47 | ContentValues values = new ContentValues(); 48 | values.clear(); 49 | values.put(AccountContract.NAME, "Yamada Tarou"); 50 | getContentResolver().insert(AccountContract.CONTENT_URI, values); 51 | 52 | // bulkInsert test 53 | ContentValues[] contentValues = new ContentValues[TEST_ENTRY_COUNT]; 54 | for (int i = 0; i < TEST_ENTRY_COUNT; i++) { 55 | values = new ContentValues(); 56 | values.clear(); 57 | values.put(AccountContract.NAME, "Yamada Tarou: " + i); 58 | contentValues[i] = values; 59 | } 60 | getContentResolver().bulkInsert(AccountContract.CONTENT_URI, contentValues); 61 | 62 | // select test 63 | Cursor c = getContentResolver().query(AccountContract.CONTENT_URI, null, null, null, null); 64 | c.moveToFirst(); 65 | do { 66 | for (int i = 0; i < c.getColumnCount(); i++) { 67 | Log.d(getClass().getSimpleName(), c.getColumnName(i) + " : " + c.getString(i)); 68 | } 69 | } while (c.moveToNext()); 70 | c.close(); 71 | 72 | // applyBatch test 73 | ArrayList operations = new ArrayList(); 74 | operations.add(ContentProviderOperation.newInsert(AccountContract.CONTENT_URI).withValue(AccountContract.NAME, "Yamada Hanako 1").build()); 75 | operations.add(ContentProviderOperation.newInsert(AccountContract.CONTENT_URI).withValue(AccountContract.NAME, "Yamada Hanako 2").build()); 76 | try { 77 | getContentResolver().applyBatch(AccountContract.AUTHORITY, operations); 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | 82 | // ContentProviderClient test 83 | ContentProviderClient client = getContentResolver().acquireContentProviderClient(AccountContract.CONTENT_URI); 84 | Cursor c2 = null; 85 | try { 86 | c2 = client.query(AccountContract.CONTENT_URI, null, null, null, null); 87 | c2.moveToFirst(); 88 | do { 89 | for (int i = 0; i < c2.getColumnCount(); i++) { 90 | Log.d(getClass().getSimpleName(), c2.getColumnName(i) + " : " + c2.getString(i)); 91 | } 92 | } while (c2.moveToNext()); 93 | } catch (RemoteException e) { 94 | e.printStackTrace(); 95 | } finally { 96 | if (c2 != null) { 97 | c2.close(); 98 | } 99 | } 100 | client.release(); 101 | } 102 | 103 | @Override 104 | public boolean onCreateOptionsMenu(Menu menu) { 105 | // Inflate the menu; this adds items to the action bar if it is present. 106 | getMenuInflater().inflate(R.menu.activity_main, menu); 107 | return true; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/model/Account.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.sample.model; 23 | 24 | import android.provider.BaseColumns; 25 | 26 | import com.j256.ormlite.field.DatabaseField; 27 | import com.j256.ormlite.table.DatabaseTable; 28 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentMimeTypeVnd; 29 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultContentUri; 30 | import com.tojc.ormlite.android.annotation.AdditionalAnnotation.DefaultSortOrder; 31 | import com.tojc.ormlite.android.ormlitecontentprovider.sample.provider.AccountContract; 32 | 33 | @DatabaseTable(tableName = AccountContract.TABLE_NAME) 34 | @DefaultContentUri(authority = AccountContract.AUTHORITY, path = AccountContract.CONTENT_URI_PATH) 35 | @DefaultContentMimeTypeVnd(name = AccountContract.MIMETYPE_NAME, type = AccountContract.MIMETYPE_TYPE) 36 | public class Account { 37 | 38 | @DatabaseField(columnName = BaseColumns._ID, generatedId = true) 39 | @DefaultSortOrder 40 | private int id; 41 | 42 | @DatabaseField 43 | private String name; 44 | 45 | public Account() { 46 | // ORMLite needs a no-arg constructor 47 | } 48 | 49 | public Account(String name) { 50 | this.id = 0; 51 | this.name = name; 52 | } 53 | 54 | public int getId() { 55 | return id; 56 | } 57 | 58 | public String getName() { 59 | return name; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/provider/AccountContract.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.sample.provider; 23 | 24 | import android.content.ContentResolver; 25 | import android.net.Uri; 26 | import android.provider.BaseColumns; 27 | 28 | public final class AccountContract implements BaseColumns { 29 | 30 | private AccountContract() { 31 | // Utility constructor 32 | } 33 | 34 | public static final String TABLE_NAME = "Account"; 35 | 36 | public static final String AUTHORITY = "com.tojc.ormlite.android.ormlitecontentprovider.sample"; 37 | 38 | public static final String CONTENT_URI_PATH = "accounts"; 39 | 40 | public static final String MIMETYPE_TYPE = "accounts"; 41 | public static final String MIMETYPE_NAME = "com.tojc.ormlite.android.ormlitecontentprovider.sample.provider"; 42 | 43 | public static final int CONTENT_URI_PATTERN_MANY = 1; 44 | public static final int CONTENT_URI_PATTERN_ONE = 2; 45 | 46 | public static final Uri CONTENT_URI = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).appendPath(CONTENT_URI_PATH).build(); 47 | 48 | public static final String NAME = "name"; 49 | } 50 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/provider/SampleHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.sample.provider; 23 | 24 | import java.sql.SQLException; 25 | 26 | import android.content.Context; 27 | import android.database.sqlite.SQLiteDatabase; 28 | 29 | import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; 30 | import com.j256.ormlite.support.ConnectionSource; 31 | import com.j256.ormlite.table.TableUtils; 32 | import com.tojc.ormlite.android.ormlitecontentprovider.sample.model.Account; 33 | 34 | public class SampleHelper extends OrmLiteSqliteOpenHelper { 35 | public SampleHelper(Context context) { 36 | super(context, "MyDatabase", null, 1); 37 | } 38 | 39 | @Override 40 | public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) { 41 | try { 42 | TableUtils.createTableIfNotExists(connectionSource, Account.class); 43 | } catch (SQLException e) { 44 | e.printStackTrace(); 45 | } 46 | } 47 | 48 | @Override 49 | public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) { 50 | try { 51 | TableUtils.dropTable(connectionSource, Account.class, true); 52 | TableUtils.createTable(connectionSource, Account.class); 53 | } catch (SQLException e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ormlite-content-provider-sample/src/com/tojc/ormlite/android/ormlitecontentprovider/sample/provider/SampleProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Android-OrmLiteContentProvider package. 3 | * 4 | * Copyright (c) 2012, Android-OrmLiteContentProvider Team. 5 | * Jaken Jarvis (jaken.jarvis@gmail.com) 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 | * 19 | * The author may be contacted via 20 | * https://github.com/jakenjarvis/Android-OrmLiteContentProvider 21 | */ 22 | package com.tojc.ormlite.android.ormlitecontentprovider.sample.provider; 23 | 24 | import com.tojc.ormlite.android.OrmLiteSimpleContentProvider; 25 | import com.tojc.ormlite.android.framework.MatcherController; 26 | import com.tojc.ormlite.android.framework.MimeTypeVnd.SubType; 27 | import com.tojc.ormlite.android.ormlitecontentprovider.sample.model.Account; 28 | 29 | public class SampleProvider extends OrmLiteSimpleContentProvider { 30 | @Override 31 | protected Class getHelperClass() { 32 | return SampleHelper.class; 33 | } 34 | 35 | @Override 36 | public boolean onCreate() { 37 | setMatcherController(new MatcherController()// 38 | .add(Account.class, SubType.DIRECTORY, "", AccountContract.CONTENT_URI_PATTERN_MANY)// 39 | .add(Account.class, SubType.ITEM, "#", AccountContract.CONTENT_URI_PATTERN_ONE)); 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /pom.gradle: -------------------------------------------------------------------------------- 1 | project.ext.customizePom = { Closure customize -> 2 | customize.resolveStrategy = Closure.DELEGATE_ONLY 3 | customize.delegate = project.ext.customizePomValue 4 | customize() 5 | } 6 | project.ext.customizePomValue = new Object() { 7 | def String name 8 | def String description 9 | } 10 | 11 | modifyPom { 12 | project { 13 | if(customizePomValue.name) { name customizePomValue.name } 14 | if(customizePomValue.description) { description customizePomValue.description } 15 | 16 | url "https://github.com/jakenjarvis/Android-OrmLiteContentProvider/" 17 | inceptionYear "2012" 18 | 19 | scm { 20 | url "https://github.com/jakenjarvis/Android-OrmLiteContentProvider/" 21 | connection "scm:git:git://github.com/jakenjarvis/Android-OrmLiteContentProvider.git" 22 | developerConnection "scm:git:git@github.com:jakenjarvis/Android-OrmLiteContentProvider.git" 23 | tag project.version.contains("SNAPSHOT") ? "HEAD" : "Ver${project.version}" 24 | } 25 | 26 | developers { 27 | developer { 28 | id "jakenjarvis" 29 | name "Jaken Jarvis" 30 | email "jaken.jarvis@gmail.com" 31 | url "https://github.com/jakenjarvis" 32 | roles { 33 | role "architect" 34 | role "developer" 35 | } 36 | timezone "+9" 37 | } 38 | } 39 | 40 | contributors { 41 | contributor { 42 | name "Stephane NICOLAS" 43 | email "snicolas@octo.com" 44 | url "https://github.com/stephanenicolas" 45 | organization "octo-online" 46 | organizationUrl "http://www.octo.com" 47 | roles { 48 | role "developer" 49 | } 50 | timezone "+1" 51 | } 52 | } 53 | 54 | licenses { 55 | license { 56 | name "Apache License, Version 2.0" 57 | url "http://www.apache.org/licenses/LICENSE-2.0.txt" 58 | distribution "repo" 59 | } 60 | } 61 | 62 | organization { 63 | name "Android-OrmLiteContentProvider Team" 64 | url "https://github.com/jakenjarvis/Android-OrmLiteContentProvider" 65 | } 66 | 67 | issueManagement { 68 | system "GitHub Issues" 69 | url "https://github.com/jakenjarvis/Android-OrmLiteContentProvider/issues" 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':ormlite-content-provider-library' 2 | include ':ormlite-content-provider-library-test' 3 | include ':ormlite-content-provider-sample' 4 | include ':ormlite-content-provider-compiler' 5 | include ':ormlite-content-provider-compiler-sample' 6 | -------------------------------------------------------------------------------- /wait_for_emulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bootanim="" 4 | failcounter=0 5 | until [[ "$bootanim" =~ "stopped" ]]; do 6 | bootanim=`adb -e shell getprop init.svc.bootanim 2>&1` 7 | echo "$bootanim" 8 | if [[ "$bootanim" =~ "not found" ]]; then 9 | let "failcounter += 1" 10 | if [[ $failcounter -gt 3 ]]; then 11 | echo "Failed to start emulator" 12 | exit 1 13 | fi 14 | fi 15 | sleep 1 16 | done 17 | echo "Done" 18 | --------------------------------------------------------------------------------