private void emitURIs() throws IOException { writer.emitEmptyLine(); for (Table table : mModel.getTables()) { writer.emitField( "Uri", SqlUtil.URI(table), EnumSet.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL), "Uri.parse(\"content://" + mModel.getContentAuthority() + "/" + table.name.toLowerCase() + "\")"); } for (View view : mModel.getViews()) { writer.emitField( "Uri", SqlUtil.URI(view), EnumSet.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL), "Uri.parse(\"content://" + mModel.getContentAuthority() + "/" + view.name.toLowerCase() + "\")"); } writer.emitEmptyLine(); }
private void emitFields() throws IOException { writer.emitEmptyLine(); writer.emitField( "String", "TAG", EnumSet.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), "\"" + mModel.getContentProviderName() + "\""); writer.emitField( "String", "DATABASE_NAME", EnumSet.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), "\"" + mModel.getDbClassName() + ".db\""); writer.emitField( "int", "DATABASE_VERSION", EnumSet.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), mModel.getDbVersion()); writer.emitField( "String", "ROW_ID", EnumSet.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL), "\"" + Table.ANDROID_ID + "\""); writer.emitEmptyLine(); writer.emitField( "String", "AUTHORITY", EnumSet.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL), "\"" + mModel.getContentAuthority() + "\""); writer.emitEmptyLine(); writer.emitField(mModel.getDbClassName(), "mLocalDatabase", EnumSet.of(Modifier.PRIVATE)); writer.emitEmptyLine(); }
private void emitURIMatcher() throws IOException { writer.emitEmptyLine(); writer.emitField( "UriMatcher", "uriMatcher", EnumSet.of(Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL)); writer.beginInitializer(true); writer.emitStatement("uriMatcher = new UriMatcher(UriMatcher.NO_MATCH)"); for (Table table : mModel.getTables()) { writer.emitStatement( "uriMatcher.addURI(\"" + mModel.getContentAuthority() + "\", \"" + table.name.toLowerCase() + "\", " + table.getAllName() + ")"); writer.emitStatement( "uriMatcher.addURI(\"" + mModel.getContentAuthority() + "\", \"" + table.name.toLowerCase() + "/#\", " + table.getSingleName() + ")"); } for (View view : mModel.getViews()) { writer.emitStatement( "uriMatcher.addURI(\"" + mModel.getContentAuthority() + "\", \"" + view.name.toLowerCase() + "\", " + SqlUtil.IDENTIFIER(view) + ")"); } writer.endInitializer(); }