diff --git a/car_srv/clients/flash/build.gradle b/car_srv/clients/flash/build.gradle index 0a9f8cf8509..4c6209147ec 100644 --- a/car_srv/clients/flash/build.gradle +++ b/car_srv/clients/flash/build.gradle @@ -21,12 +21,26 @@ repositories { mavenCentral() } +task compileProto(type: Exec) { + executable "./compileProto.sh" +} +task buildProtoLib(type: Copy) { + //just copy lib src to project + def pathToProtoKotSrc = "../../../proto/compiler/src/" + from pathToProtoKotSrc + "CodedInputStream.kt", pathToProtoKotSrc + "CodedOutputStream.kt", + pathToProtoKotSrc + "WireFormat.kt", pathToProtoKotSrc + "WireType.kt", + pathToProtoKotSrc + "InvalidProtocolBufferException.kt" + into "src/main/java" +} + task getDeps(type: Copy) { from sourceSets.main.compileClasspath into 'build/libs' } build.dependsOn getDeps +compileKotlin.dependsOn compileProto +compileProto.dependsOn buildProtoLib jar { manifest { @@ -40,7 +54,7 @@ jar { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile group: "com.martiansoftware",name:"jsap",version:"2.1" + compile group: "com.martiansoftware", name: "jsap", version: "2.1" compile "com.google.protobuf:protobuf-java:3.0.0-beta-3" compile "io.netty:netty-all:4.1.2.Final" diff --git a/car_srv/clients/flash/compileProto.sh b/car_srv/clients/flash/compileProto.sh new file mode 100755 index 00000000000..411b0dab221 --- /dev/null +++ b/car_srv/clients/flash/compileProto.sh @@ -0,0 +1 @@ +../../../proto/compiler/google/src/google/protobuf/compiler/kotlin/protoc --kotlin_out="./src/main/java" --proto_path="../../../proto" ../../../proto/carkot.proto diff --git a/car_srv/clients/flash/src/main/java/CodedInputStream.kt b/car_srv/clients/flash/src/main/java/CodedInputStream.kt new file mode 100644 index 00000000000..382cdf620ce --- /dev/null +++ b/car_srv/clients/flash/src/main/java/CodedInputStream.kt @@ -0,0 +1,305 @@ +import java.nio.ByteBuffer +import java.nio.ByteOrder +import WireFormat.VARINT_INFO_BITS_COUNT +import WireFormat.VARINT_INFO_BITS_MASK +import WireFormat.VARINT_UTIL_BIT_MASK + +/** + * Created by Dmitry Savvinov on 7/6/16. + * + * Hides details of work with Protobuf encoding + * + * Note that CodedInputStream reads protobuf-defined types from stream (such as int32, sint32, etc), + * while CodedOutputStream has methods for writing Kotlin-types (such as Boolean, Int, Long, Short, etc) + * + */ + +// TODO: refactor correctness checks into readTag +class CodedInputStream(input: java.io.InputStream) { + val bufferedInput: java.io.BufferedInputStream + init { + bufferedInput = java.io.BufferedInputStream(input) // TODO: Java's realization uses hand-written buffers. Why? + } + + fun readInt32(expectedFieldNumber: Int): Int { + val tag = readTag(expectedFieldNumber, WireType.VARINT) + val actualFieldNumber = WireFormat.getTagFieldNumber(tag) + val actualWireType = WireFormat.getTagWireType(tag) + checkFieldCorrectness(expectedFieldNumber, actualFieldNumber, WireType.VARINT, actualWireType) + return readInt32NoTag() + } + + // Note that unsigned integer types are stored as their signed counterparts with top bit + // simply stored in the sign bit - similar to Java's protobuf implementation. Hence, all + // methods reading unsigned ints simply redirect call to corresponding signed-reading method + fun readUInt32(expectedFieldNumber: Int): Int { + val tag = readTag(expectedFieldNumber, WireType.VARINT) + return readUInt32NoTag() + } + + fun readUInt32NoTag(): Int { + return readInt32NoTag() + } + + fun readInt64(expectedFieldNumber: Int): Long { + val tag = readTag(expectedFieldNumber, WireType.VARINT) + return readInt64NoTag() + } + + // See note on unsigned integers implementations above + fun readUInt64(expectedFieldNumber: Int): Long { + val tag = readTag(expectedFieldNumber, WireType.VARINT) + return readUInt64NoTag() + } + + fun readUInt64NoTag(): Long { + return readInt64NoTag() + } + + fun readBool(expectedFieldNumber: Int): Boolean { + val tag = readTag(expectedFieldNumber, WireType.VARINT) + return readBoolNoTag() + } + + fun readBoolNoTag(): Boolean { + val readValue = readInt32NoTag() + val boolValue = when (readValue) { + 0 -> false + 1 -> true + else -> throw InvalidProtocolBufferException("Expected boolean-encoding (1 or 0), got $readValue") + } + return boolValue + } + + // Reading enums is like reading one int32 number. Caller is responsible for converting this ordinal to enum-object + fun readEnum(expectedFieldNumber: Int): Int { + val tag = readTag(expectedFieldNumber, WireType.VARINT) + return readEnumNoTag() + } + + fun readEnumNoTag(): Int { + return readUInt32NoTag() + } + + fun readSInt32(expectedFieldNumber: Int): Int { + val tag = readTag(expectedFieldNumber, WireType.VARINT) + return readSInt32NoTag() + } + + fun readSInt32NoTag(): Int { + return readZigZag32NoTag() + } + + fun readSInt64(expectedFieldNumber: Int): Long { + val tag = readTag(expectedFieldNumber, WireType.VARINT) + return readZigZag64NoTag() + } + + fun readFixed32(expectedFieldNumber: Int): Int { + val tag = readTag(expectedFieldNumber, WireType.FIX_32) + return readFixed32NoInt() + } + + fun readFixed32NoInt(): Int { + return readLittleEndianInt() + } + + fun readSFixed32(expectedFieldNumber: Int): Int { + val tag = readTag(expectedFieldNumber, WireType.FIX_32) + return readSFixed32NoTag() + } + + fun readSFixed32NoTag(): Int { + return readLittleEndianInt() + } + + fun readFixed64(expectedFieldNumber: Int): Long { + val tag = readTag(expectedFieldNumber, WireType.FIX_64) + return readFixed64NoTag() + } + + fun readFixed64NoTag(): Long { + return readLittleEndianLong() + } + + fun readSFixed64(expectedFieldNumber: Int): Long { + val tag = readTag(expectedFieldNumber, WireType.FIX_64) + return readSFixed64NoTag() + } + + fun readSFixed64NoTag(): Long { + return readLittleEndianLong() + } + + fun readDouble(expectedFieldNumber: Int): Double { + val tag = readTag(expectedFieldNumber, WireType.FIX_64) + return readDoubleNoTag() + } + + fun readDoubleNoTag(): Double { + return readLittleEndianDouble() + } + + fun readFloat(expectedFieldNumber: Int): Float { + val tag = readTag(expectedFieldNumber, WireType.FIX_32) + return readFloatNoTag() + } + + fun readFloatNoTag(): Float { + return readLittleEndianFloat() + } + + fun readString(expectedFieldNumber: Int): String { + val tag = readTag(expectedFieldNumber, WireType.LENGTH_DELIMITED) + return readStringNoTag() + } + + fun readStringNoTag(): String { + val length = readInt32NoTag() + val value = String(readRawBytes(length)) + return value + } + + fun readBytes(expectedFieldNumber: Int): ByteArray { + val tag = readTag(expectedFieldNumber, WireType.LENGTH_DELIMITED) + return readBytesNoTag() + } + + fun readBytesNoTag(): ByteArray { + val length = readInt32NoTag() + return readRawBytes(length) + } + + /** ============ Utility methods ================== + * They are left non-private for cases when one wants to implement her/his own protocol format. + * Then she/he can re-use low-level methods for operating with raw values, that are not annotated with Protobuf tags. + */ + + fun checkFieldCorrectness( + expectedFieldNumber: Int, + actualFieldNumber: Int, + expectedWireType: WireType, + actualWireType: WireType) { + if (expectedFieldNumber != actualFieldNumber) { + throw InvalidProtocolBufferException( + "Error in protocol format: \n " + + "Expected field number ${expectedFieldNumber}, got ${actualFieldNumber}") + } + + if (expectedWireType != actualWireType) { + throw InvalidProtocolBufferException("Error in protocol format: \n " + + "Expected ${expectedWireType.name} type, got ${actualWireType.name}") + } + } + + fun readLittleEndianDouble(): Double { + val byteBuffer = ByteBuffer.wrap(readRawBytes(8)) + byteBuffer.order(ByteOrder.LITTLE_ENDIAN) + return byteBuffer.getDouble(0) + } + + fun readLittleEndianFloat(): Float { + val byteBuffer = ByteBuffer.wrap(readRawBytes(4)) + byteBuffer.order(ByteOrder.LITTLE_ENDIAN) + return byteBuffer.getFloat(0) + } + + fun readLittleEndianInt(): Int { + val byteBuffer = ByteBuffer.wrap(readRawBytes(8)) + byteBuffer.order(ByteOrder.LITTLE_ENDIAN) + return byteBuffer.getInt(0) + } + + fun readLittleEndianLong(): Long { + val byteBuffer = ByteBuffer.wrap(readRawBytes(4)) + byteBuffer.order(ByteOrder.LITTLE_ENDIAN) + return byteBuffer.getLong(0) + } + + fun readRawBytes(count: Int): ByteArray { + val ba = ByteArray(count) + for (i in 0..(count - 1)) { + ba[i] = bufferedInput.read().toByte() + } + return ba + } + + // reads tag. Note that it returns 0 for the end of message! + fun readTag(expectedFieldNumber: Int, expectedWireType: WireType): Int { + if (isAtEnd()) { + return 0 // we can safely return 0 as sign of end of message, because 0-tags are illegal + } + val tag = readInt32NoTag() + if (tag == 0) { // if we somehow had read 0-tag, then message is corrupted + throw InvalidProtocolBufferException("Invalid tag 0") + } + + val actualFieldNumber = WireFormat.getTagFieldNumber(tag) + val actualWireType = WireFormat.getTagWireType(tag) + checkFieldCorrectness(expectedFieldNumber, actualFieldNumber, expectedWireType, actualWireType) + return tag + } + + // reads varint not larger than 32-bit integer according to protobuf varint-encoding + fun readInt32NoTag(): Int { + var done: Boolean = false + var result: Int = 0 + var step: Int = 0 + while (!done) { + val byte: Int = bufferedInput.read() + result = result or + ( + (byte and VARINT_INFO_BITS_MASK) + shl + (VARINT_INFO_BITS_COUNT * step) + ) + step++ + if ((byte and VARINT_UTIL_BIT_MASK) == 0) { + done = true + } + } + return result + } + + // reads varint not larger than 64-bit integer according to protobuf varint-encoding + fun readInt64NoTag(): Long { + var done: Boolean = false + var result: Long = 0 + var step: Int = 0 + while (!done) { + val byte: Int = bufferedInput.read() + result = result or + ( + (byte and VARINT_INFO_BITS_MASK).toLong() + shl + (VARINT_INFO_BITS_COUNT * step) + ) + step++ + if ((byte and VARINT_UTIL_BIT_MASK) == 0 || byte == -1) { + done = true + } + } + return result + } + + // reads zig-zag encoded integer not larger than 32-bit long + fun readZigZag32NoTag(): Int { + val value = readInt32NoTag() + return (value shr 1) xor (-(value and 1)) // bit magic for decoding zig-zag number + } + + // reads zig-zag encoded integer not larger than 64-bit long + fun readZigZag64NoTag(): Long { + val value = readInt64NoTag() + return (value shr 1) xor (-(value and 1L)) // bit magic for decoding zig-zag number + } + + // checks if at least one more byte can be read from underlying input stream + fun isAtEnd(): Boolean { + bufferedInput.mark(1) + val byte = bufferedInput.read() + bufferedInput.reset() + return byte == -1 + } +} + diff --git a/car_srv/clients/flash/src/main/java/CodedOutputStream.kt b/car_srv/clients/flash/src/main/java/CodedOutputStream.kt new file mode 100644 index 00000000000..646189cfd8f --- /dev/null +++ b/car_srv/clients/flash/src/main/java/CodedOutputStream.kt @@ -0,0 +1,258 @@ +import java.nio.ByteBuffer +import java.nio.ByteOrder +import WireFormat.VARINT_INFO_BITS_COUNT +import WireFormat.VARINT_INFO_BITS_MASK +import WireFormat.VARINT_UTIL_BIT_MASK + +/** + * Created by user on 7/6/16. + */ + +class CodedOutputStream(val output: java.io.OutputStream) { + fun writeTag(fieldNumber: Int, type: WireType) { + val tag = (fieldNumber shl 3) or type.ordinal + writeInt32NoTag(tag) + } + + fun writeInt32(fieldNumber: Int, value: Int?) { + value ?: return + writeTag(fieldNumber, WireType.VARINT) + writeInt32NoTag(value) + } + + // Note that unsigned integer types are stored as their signed counterparts with top bit + // simply stored in the sign bit - similar to Java's protobuf implementation. Hence, all + // methods, writing unsigned ints simply redirect call to corresponding signed-writing method + fun writeUInt32(fieldNumber: Int, value: Int?) { + value ?: return + writeInt32(fieldNumber, value) + } + + fun writeInt64(fieldNumber: Int, value: Long?) { + value ?: return + writeTag(fieldNumber, WireType.VARINT) + writeInt64NoTag(value) + } + + // See notes on unsigned integers implementation above + fun writeUInt64(fieldNumber: Int, value: Long?) { + value ?: return + writeInt64(fieldNumber, value) + } + + fun writeBool(fieldNumber: Int, value: Boolean?) { + value ?: return + writeTag(fieldNumber, WireType.VARINT) + writeBoolNoTag(value) + } + + fun writeBoolNoTag(value: Boolean) { + writeInt32NoTag(if (value) 1 else 0) + } + + // Writing enums is like writing one int32 number. Caller is responsible for converting enum-object to ordinal + fun writeEnum(fieldNumber: Int, value: Int?) { + value ?: return + writeTag(fieldNumber, WireType.VARINT) + writeEnumNoTag(value) + } + + fun writeEnumNoTag(value: Int) { + writeInt32NoTag(value) + } + + fun writeSInt32(fieldNumber: Int, value: Int?) { + value ?: return + writeTag(fieldNumber, WireType.VARINT) + writeSInt32NoTag(value) + } + + fun writeSInt32NoTag(value: Int) { + writeInt32NoTag((value shl 1) xor (value shr 31)) + } + + fun writeSInt64(fieldNumber: Int, value: Long?) { + value ?: return + writeTag(fieldNumber, WireType.VARINT) + writeSInt64NoTag(value) + } + + fun writeSInt64NoTag(value: Long) { + writeInt64NoTag((value shl 1) xor (value shr 63)) + } + + fun writeFixed32(fieldNumber: Int, value: Int?) { + value ?: return + writeTag(fieldNumber, WireType.FIX_32) + writeFixed32NoTag(value) + } + + fun writeFixed32NoTag(value: Int) { + writeLittleEndian(value) + } + + // See notes on unsigned integers implementation above + fun writeSFixed32(fieldNumber: Int, value: Int?) { + value ?: return + writeTag(fieldNumber, WireType.FIX_32) + writeSFixed32NoTag(value) + } + + fun writeSFixed32NoTag(value: Int) { + writeLittleEndian(value) + } + + fun writeFixed64(fieldNumber: Int, value: Long?) { + value ?: return + writeTag(fieldNumber, WireType.FIX_64) + writeFixed64NoTag(value) + } + + fun writeFixed64NoTag(value: Long) { + writeLittleEndian(value) + } + + // See notes on unsigned integers implementation above + fun writeSFixed64(fieldNumber: Int, value: Long?) { + value ?: return + writeTag(fieldNumber, WireType.FIX_64) + writeSFixed64NoTag(value) + } + + fun writeSFixed64NoTag(value: Long) { + writeLittleEndian(value) + } + + fun writeDouble(fieldNumber: Int, value: Double?) { + value ?: return + writeTag(fieldNumber, WireType.FIX_64) + writeDoubleNoTag(value) + } + + fun writeDoubleNoTag(value: Double) { + writeLittleEndian(value) + } + + fun writeFloat(fieldNumber: Int, value: Float?) { + value ?: return + writeTag(fieldNumber, WireType.FIX_32) + writeFloatNoTag(value) + } + + fun writeFloatNoTag(value: Float) { + writeLittleEndian(value) + } + + fun writeString(fieldNumber: Int, value: String?) { + value ?: return + writeTag(fieldNumber, WireType.LENGTH_DELIMITED) + writeStringNoTag(value) + } + + fun writeStringNoTag(value: String) { + writeInt32NoTag(value.length) + output.write(value.toByteArray(Charsets.UTF_8)) + } + + fun writeBytes(fieldNumber: Int, value: ByteArray?) { + value ?: return + writeTag(fieldNumber, WireType.LENGTH_DELIMITED) + writeBytesNoTag(value) + } + + fun writeBytesNoTag(value: ByteArray) { + writeInt32NoTag(value.size) + output.write(value) + } + + /** ============ Utility methods ================== + * They are left non-private for cases when one wants to implement her/his own protocol format. + * Then she/he can re-use low-level methods for operating with raw values, that are not annotated with Protobuf tags. + */ + + fun writeLittleEndian(value: Int?) { + value ?: return + val bb = ByteBuffer.allocate(4) + bb.order(ByteOrder.LITTLE_ENDIAN) + bb.putInt(value) + output.write(bb.array()) + } + + fun writeLittleEndian(value: Long?) { + value ?: return + val bb = ByteBuffer.allocate(8) + bb.order(ByteOrder.LITTLE_ENDIAN) + bb.putLong(value) + output.write(bb.array()) + } + + fun writeLittleEndian(value: Double?) { + value ?: return + val bb = ByteBuffer.allocate(8) + bb.order(ByteOrder.LITTLE_ENDIAN) + bb.putDouble(value) + output.write(bb.array()) + } + + fun writeLittleEndian(value: Float?) { + value ?: return + val bb = ByteBuffer.allocate(4) + bb.order(ByteOrder.LITTLE_ENDIAN) + bb.putFloat(value) + output.write(bb.array()) + } + + fun writeInt32NoTag(value: Int?) { + value ?: return + var curValue: Int = value + + // we have at most 32 information bits. With overhead of 1 bit per 7 bits we need at most 5 bytes for encoding + val res = ByteArray(5) + + var resSize = 0 + do { + // encode current 7 bits + var curByte = (curValue and WireFormat.VARINT_INFO_BITS_MASK) + + // discard encoded bits. Note that unsigned shift is needed for cases with negative numbers + curValue = curValue ushr VARINT_INFO_BITS_COUNT + + // check if there will be next byte in encoding and set util bit if needed + if (curValue != 0) { + curByte = curByte or VARINT_UTIL_BIT_MASK + } + + res[resSize] = curByte.toByte() + resSize++ + } while(curValue != 0) + output.write(res, 0, resSize) + } + + fun writeInt64NoTag(value: Long?) { + value ?: return + var curValue: Long = value + + // we have at most 64 information bits. With overhead of 1 bit per 7 bits we need at most 10 bytes for encoding + val res = ByteArray(10) + + var resSize = 0 + while(curValue != 0L) { + // encode current 7 bits + var curByte = (curValue and VARINT_INFO_BITS_MASK.toLong()) + + // discard encoded bits. Note that unsigned shift is needed for cases with negative numbers + curValue = curValue ushr VARINT_INFO_BITS_COUNT + + // check if there will be next byte and set util bit if needed + if (curValue != 0L) { + curByte = curByte or VARINT_UTIL_BIT_MASK.toLong() + } + + res[resSize] = curByte.toByte() + resSize++ + } + output.write(res, 0, resSize) + } + + +} diff --git a/car_srv/clients/flash/src/main/java/InvalidProtocolBufferException.kt b/car_srv/clients/flash/src/main/java/InvalidProtocolBufferException.kt new file mode 100644 index 00000000000..91f59d8a91e --- /dev/null +++ b/car_srv/clients/flash/src/main/java/InvalidProtocolBufferException.kt @@ -0,0 +1,10 @@ +/** + * Created by user on 7/7/16. + */ + +class InvalidProtocolBufferException( + override val message: String? = null, + override val cause : Throwable? = null + ) : Throwable(message, cause) { + +} \ No newline at end of file diff --git a/car_srv/clients/flash/src/main/java/Main.kt b/car_srv/clients/flash/src/main/java/Main.kt index 3c54d0af568..2fbcf0fd731 100644 --- a/car_srv/clients/flash/src/main/java/Main.kt +++ b/car_srv/clients/flash/src/main/java/Main.kt @@ -4,7 +4,6 @@ import com.martiansoftware.jsap.JSAP import com.martiansoftware.jsap.JSAPResult import io.netty.buffer.Unpooled import io.netty.handler.codec.http.* -import proto.Carkot import java.io.File import java.io.FileInputStream import java.io.IOException @@ -46,17 +45,17 @@ fun main(args: Array) { return; } - val bytesBinTest = Carkot.Upload.newBuilder().setData(ByteString.copyFrom(fileBytes)).setBase(mcuSystem).build().toByteArray() - val request = DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/loadBin", Unpooled.copiedBuffer(bytesBinTest)); - request.headers().set(HttpHeaderNames.HOST, host) - request.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE) - request.headers().setInt(HttpHeaderNames.CONTENT_LENGTH, request.content().readableBytes()) - request.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8") - - client.Client.sendRequest(request, host, port) - println(client.ClientHandler.requestResult.code) - println(client.ClientHandler.requestResult.stdErr) - println(client.ClientHandler.requestResult.stdOut) +// val bytesBinTest = Carkot.Upload.newBuilder().setData(ByteString.copyFrom(fileBytes)).setBase(mcuSystem).build().toByteArray() +// val request = DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/loadBin", Unpooled.copiedBuffer(bytesBinTest)); +// request.headers().set(HttpHeaderNames.HOST, host) +// request.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE) +// request.headers().setInt(HttpHeaderNames.CONTENT_LENGTH, request.content().readableBytes()) +// request.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8") +// +// client.Client.sendRequest(request, host, port) +// println(client.ClientHandler.requestResult.code) +// println(client.ClientHandler.requestResult.stdErr) +// println(client.ClientHandler.requestResult.stdOut) } fun saveFileConfig(actualValues: Map) { @@ -102,7 +101,6 @@ fun readFileConfig(): Map { result.put(keyValuePair[0], keyValuePair[1]) } } - } } catch (e: IOException) { diff --git a/car_srv/clients/flash/src/main/java/WireFormat.kt b/car_srv/clients/flash/src/main/java/WireFormat.kt new file mode 100644 index 00000000000..1caabc33a9c --- /dev/null +++ b/car_srv/clients/flash/src/main/java/WireFormat.kt @@ -0,0 +1,114 @@ +/** + * Created by user on 7/6/16. + */ + + +object WireFormat { + // couple of constants for magic numbers + val TAG_TYPE_BITS: Int = 3 + val TAG_TYPE_MASK: Int = (1 shl TAG_TYPE_BITS) - 1 + val VARINT_INFO_BITS_COUNT: Int = 7 + val VARINT_INFO_BITS_MASK: Int = 0b01111111 // mask for separating lowest 7 bits, where actual information stored + val VARINT_UTIL_BIT_MASK: Int = 0b10000000 // mask for separating highest bit, that indicates next byte presence + val FIXED_32_BYTE_SIZE: Int = 4 + val FIXED_64_BYTE_SIZE: Int = 8 + + fun getTagWireType(tag: Int): WireType { + return WireType from (tag and TAG_TYPE_MASK).toByte() + } + + fun getTagFieldNumber(tag: Int): Int { + return tag ushr TAG_TYPE_BITS + } + + // TODO: refactor casts into function overloading as soon as translator will support it + fun getTagSize(fieldNumber: Int, wireType: WireType): Int { + return getVarint32Size((fieldNumber shl 3) or wireType.ordinal) + } + + fun getVarint32Size(value: Int): Int { + var curValue = value + var size = 0 + while (curValue != 0) { + size += 1 + curValue = value ushr VARINT_INFO_BITS_COUNT + } + return size + } + + fun getVarint64Size(value: Long): Int { + var curValue = value + var size = 0 + while (curValue != 0L) { + size += 1 + curValue = value ushr VARINT_INFO_BITS_COUNT + } + return size + } + + fun getZigZag32Size(value: Int): Int { + return getVarint32Size((value shl 1) xor (value shr 31)) + } + + fun getZigZag64Size(value: Long): Int { + return getVarint64Size((value shl 1) xor (value shr 63)) + } + + fun getInt32Size(fieldNumber: Int, value: Int): Int { + return getTagSize(fieldNumber, WireType.VARINT) + getVarint32Size(value) + } + + fun getUInt32Size(fieldNumber: Int, value: Int): Int { + return getInt32Size(fieldNumber, value) + } + + fun getInt64Size(fieldNumber: Int, value: Long): Int { + return getTagSize(fieldNumber, WireType.VARINT) + getVarint64Size(value) + } + + fun getUInt64Size(fieldNumber: Int, value: Long): Int { + return getInt64Size(fieldNumber, value) + } + + fun getBoolSize(fieldNumber: Int, value: Boolean): Int { + val intValue = if (value) 1 else 0 + return getInt32Size(fieldNumber, intValue) + } + + fun getEnumSize(fieldNumber: Int, value: Int): Int { + return getInt32Size(fieldNumber, value) + } + + fun getSInt32Size(fieldNumber: Int, value: Int): Int { + return getTagSize(fieldNumber, WireType.VARINT) + getZigZag32Size(value) + } + + fun getSInt64Size(fieldNumber: Int, value: Long): Int { + return getTagSize(fieldNumber, WireType.VARINT) + getZigZag64Size(value) + } + + fun getFixed32Size(fieldNumber: Int, value: Long): Int { + return getTagSize(fieldNumber, WireType.FIX_32) + FIXED_32_BYTE_SIZE + } + + fun getFixed64Size(fieldNumber: Int, value: Long): Int { + return getTagSize(fieldNumber, WireType.FIX_64) + FIXED_64_BYTE_SIZE + } + + fun getDoubleSize(fieldNumber: Int, value: Double): Int { + return getTagSize(fieldNumber, WireType.FIX_32) + FIXED_32_BYTE_SIZE + } + + fun getFloatSize(fieldNumber: Int, value: Float): Int { + return getTagSize(fieldNumber, WireType.FIX_64) + FIXED_64_BYTE_SIZE + } + + fun getStringSize(fieldNumber: Int, value: String): Int { + val encodedStringSize = value.toByteArray(Charsets.UTF_8).size //TODO: not sure if it's the best way to do it + return encodedStringSize + getTagSize(fieldNumber, WireType.LENGTH_DELIMITED) + getVarint32Size(encodedStringSize) + } + + fun getBytesSize(fieldNumber: Int, value: ByteArray): Int { + return value.size + getTagSize(fieldNumber, WireType.LENGTH_DELIMITED) + getVarint32Size(value.size) + } +} \ No newline at end of file diff --git a/car_srv/clients/flash/src/main/java/WireType.kt b/car_srv/clients/flash/src/main/java/WireType.kt new file mode 100644 index 00000000000..6cc55da3f42 --- /dev/null +++ b/car_srv/clients/flash/src/main/java/WireType.kt @@ -0,0 +1,28 @@ +/** + * Created by Dmitry Savvinov on 7/6/16. + * Enum for possible WireTypes. + * See details at [official Google reference]()https://developers.google.com/protocol-buffers/docs/encoding#structure) + */ + +enum class WireType(val id: Int) { + VARINT(0), // int32, int64, uint32, uint64, sint32, sint64, bool, enum + FIX_64(1), // fixed64, sfixed64, double + LENGTH_DELIMITED(2), // string, bytes, embedded messages, packed repeated fields + START_GROUP(3), // groups (deprecated) + END_GROUP(4), // groups (deprecated) + FIX_32(5); // fixed32, sfixed32, float + + companion object { + infix fun from (value: Byte): WireType { + return when (value) { + 0.toByte() -> VARINT + 1.toByte() -> FIX_64 + 2.toByte() -> LENGTH_DELIMITED + 3.toByte() -> START_GROUP + 4.toByte() -> END_GROUP + 5.toByte() -> FIX_32 + else -> throw IllegalArgumentException() + } + } + } +} \ No newline at end of file diff --git a/car_srv/clients/flash/src/main/java/carkot.kt b/car_srv/clients/flash/src/main/java/carkot.kt new file mode 100644 index 00000000000..755f48aa145 --- /dev/null +++ b/car_srv/clients/flash/src/main/java/carkot.kt @@ -0,0 +1,512 @@ +class Upload private constructor (data: ByteArray = ByteArray(0), base: kotlin.String = "", method: Method = Upload.Method.BuilderMethod().build()) { + var data : ByteArray + private set + + var base : kotlin.String + private set + + var method : Method + private set + + + init { + this.data = data + this.base = base + this.method = method + } + class Method private constructor (type: TYPE = Upload.Method.TYPE.fromIntToTYPE(0), port: kotlin.String = "", device: kotlin.String = "", arguments: MutableList = mutableListOf()) { + var type : TYPE + private set + + var port : kotlin.String + private set + + var device : kotlin.String + private set + + var arguments : MutableList + private set + + + init { + this.type = type + this.port = port + this.device = device + this.arguments = arguments + } + enum class TYPE(val ord: Int) { + DFU (0), + STLINK (1); + + companion object { + fun fromIntToTYPE (ord: Int): TYPE { + return when (ord) { + 0 -> TYPE.DFU + 1 -> TYPE.STLINK + else -> throw InvalidProtocolBufferException("Error: got unexpected int ${ord} while parsing TYPE "); + } + } + } + } + + fun writeTo (output: CodedOutputStream): Unit { + output.writeEnum (1, type.ord) + output.writeString (2, port) + output.writeString (3, device) + if (arguments.size > 0) { + output.writeTag(4, WireType.LENGTH_DELIMITED) + var arrayByteSize = 0 + run { + var arraySize = 0 + for (item in arguments) { + arraySize += WireFormat.getStringSize(4, item) + } + arrayByteSize += arraySize + } + output.writeInt32NoTag(arrayByteSize) + for (item in arguments) { + output.writeString (4, item) + } + } + } + + class BuilderMethod constructor (type: TYPE = Upload.Method.TYPE.fromIntToTYPE(0), port: kotlin.String = "", device: kotlin.String = "", arguments: MutableList = mutableListOf()) { + var type : TYPE + private set + fun setType(value: TYPE): Upload.Method.BuilderMethod { + type = value + return this + } + + var port : kotlin.String + private set + fun setPort(value: kotlin.String): Upload.Method.BuilderMethod { + port = value + return this + } + + var device : kotlin.String + private set + fun setDevice(value: kotlin.String): Upload.Method.BuilderMethod { + device = value + return this + } + + var arguments : MutableList + private set + fun setArguments(value: MutableList ): Upload.Method.BuilderMethod { + arguments = value + return this + } + fun setkotlin.String(index: Int, value: kotlin.String): { + arguments[index] = value + return this + } + fun addkotlin.String(value: kotlin.String): { + arguments.add(value) + return this + } + fun addAllkotlin.String(value: Iterable): { + for (item in value) { + arguments.add(item) + } + return this + } + + + init { + this.type = type + this.port = port + this.device = device + this.arguments = arguments + } + + fun readFrom (input: CodedInputStream): Upload.Method.BuilderMethod { + type = TYPE.fromIntToTYPE(input.readEnum(1)) + port = input.readString(2) + device = input.readString(3) + val tag = input.readTag(4, WireType.LENGTH_DELIMITED) + val expectedSize = input.readInt32NoTag() + var readSize = 0 + while(readSize != expectedSize) { + val tmp: kotlin.String.Builderkotlin.String = kotlin.String.Builderkotlin.String() + tmp = input.readString(4) + readSize += WireFormat.getStringSize(4, tmp) + arguments.add(tmp.build()) + } + return this +} + + fun build(): Method { + return Method(type, port, device, arguments) + } + + fun parseFieldFrom(input: CodedInputStream): Boolean { + if (input.isAtEnd()) { return false } + val tag = input.readInt32NoTag() + if (tag == 0) { return false } + val fieldNumber = WireFormat.getTagFieldNumber(tag) + val wireType = WireFormat.getTagWireType(tag) + when(fieldNumber) { + 1 -> type = TYPE.fromIntToTYPE(input.readEnumNoTag()) + 2 -> port = input.readStringNoTag() + 3 -> device = input.readStringNoTag() + 4 -> { + val expectedSize = input.readInt32NoTag() + var readSize = 0 + while(readSize != expectedSize) { + val tmp: kotlin.String.Builderkotlin.String = kotlin.String.Builderkotlin.String() + tmp = input.readString(4) + readSize += WireFormat.getStringSize(4, tmp) + arguments.add(tmp.build()) + } + } + } + return true} + fun parseFrom(input: CodedInputStream): Upload.Method.BuilderMethod { + while(parseFieldFrom(input)) {} + return this + } + fun getSize(): Int { + var size = 0 + size += WireFormat.getEnumSize(1, type.ord) + size += WireFormat.getStringSize(2, port) + size += WireFormat.getStringSize(3, device) + run { + var arraySize = 0 + for (item in arguments) { + arraySize += WireFormat.getStringSize(4, item) + } + size += arraySize + WireFormat.getTagSize(4, WireType.LENGTH_DELIMITED) + WireFormat.getVarint32Size(arraySize) + } + return size + } + } + + + fun mergeWith (other: Method) { + type = other.type + port = other.port + device = other.device + arguments.addAll(other.arguments) + } + + fun mergeFrom (input: CodedInputStream) { + val builder = Upload.Method.BuilderMethod() + mergeWith(builder.parseFrom(input).build())} + fun getSize(): Int { + var size = 0 + size += WireFormat.getEnumSize(1, type.ord) + size += WireFormat.getStringSize(2, port) + size += WireFormat.getStringSize(3, device) + run { + var arraySize = 0 + for (item in arguments) { + arraySize += WireFormat.getStringSize(4, item) + } + size += arraySize + WireFormat.getTagSize(4, WireType.LENGTH_DELIMITED) + WireFormat.getVarint32Size(arraySize) + } + return size + } + } + + + fun writeTo (output: CodedOutputStream): Unit { + output.writeBytes (1, data) + output.writeString (2, base) + output.writeTag(3, WireType.LENGTH_DELIMITED) + output.writeInt32NoTag(method.getSize()) + method.writeTo(output) + } + + class BuilderUpload constructor (data: ByteArray = ByteArray(0), base: kotlin.String = "", method: Method = Upload.Method.BuilderMethod().build()) { + var data : ByteArray + private set + fun setData(value: ByteArray): Upload.BuilderUpload { + data = value + return this + } + + var base : kotlin.String + private set + fun setBase(value: kotlin.String): Upload.BuilderUpload { + base = value + return this + } + + var method : Method + private set + fun setMethod(value: Method): Upload.BuilderUpload { + method = value + return this + } + + + init { + this.data = data + this.base = base + this.method = method + } + + fun readFrom (input: CodedInputStream): Upload.BuilderUpload { + data = input.readBytes(1) + base = input.readString(2) + input.readTag(3, WireType.LENGTH_DELIMITED) + val expectedSize = input.readInt32NoTag() + method.mergeFrom(input) + if (expectedSize != method.getSize()) { throw InvalidProtocolBufferException ("Expected size ${expectedSize} got ${method.getSize()}") } + return this +} + + fun build(): Upload { + return Upload(data, base, method) + } + + fun parseFieldFrom(input: CodedInputStream): Boolean { + if (input.isAtEnd()) { return false } + val tag = input.readInt32NoTag() + if (tag == 0) { return false } + val fieldNumber = WireFormat.getTagFieldNumber(tag) + val wireType = WireFormat.getTagWireType(tag) + when(fieldNumber) { + 1 -> data = input.readBytesNoTag() + 2 -> base = input.readStringNoTag() + 3 -> { + input.readTag(3, WireType.LENGTH_DELIMITED) + val expectedSize = input.readInt32NoTag() + method.mergeFrom(input) + if (expectedSize != method.getSize()) { throw InvalidProtocolBufferException ("Expected size ${expectedSize} got ${method.getSize()}") } + } + } + return true} + fun parseFrom(input: CodedInputStream): Upload.BuilderUpload { + while(parseFieldFrom(input)) {} + return this + } + fun getSize(): Int { + var size = 0 + size += WireFormat.getBytesSize(1, data) + size += WireFormat.getStringSize(2, base) + size += method.getSize() + WireFormat.getTagSize(3, WireType.LENGTH_DELIMITED) + WireFormat.getVarint32Size(method.getSize()) + return size + } + } + + + fun mergeWith (other: Upload) { + data.plus(other.data) + base = other.base + method = other.method + } + + fun mergeFrom (input: CodedInputStream) { + val builder = Upload.BuilderUpload() + mergeWith(builder.parseFrom(input).build())} + fun getSize(): Int { + var size = 0 + size += WireFormat.getBytesSize(1, data) + size += WireFormat.getStringSize(2, base) + size += method.getSize() + WireFormat.getTagSize(3, WireType.LENGTH_DELIMITED) + WireFormat.getVarint32Size(method.getSize()) + return size + } +} + + +class UploadResult private constructor (stdOut: kotlin.String = "", stdErr: kotlin.String = "", resultCode: Int = 0) { + var stdOut : kotlin.String + private set + + var stdErr : kotlin.String + private set + + var resultCode : Int + private set + + + init { + this.stdOut = stdOut + this.stdErr = stdErr + this.resultCode = resultCode + } + + fun writeTo (output: CodedOutputStream): Unit { + output.writeString (1, stdOut) + output.writeString (2, stdErr) + output.writeInt32 (3, resultCode) + } + + class BuilderUploadResult constructor (stdOut: kotlin.String = "", stdErr: kotlin.String = "", resultCode: Int = 0) { + var stdOut : kotlin.String + private set + fun setStdOut(value: kotlin.String): UploadResult.BuilderUploadResult { + stdOut = value + return this + } + + var stdErr : kotlin.String + private set + fun setStdErr(value: kotlin.String): UploadResult.BuilderUploadResult { + stdErr = value + return this + } + + var resultCode : Int + private set + fun setResultCode(value: Int): UploadResult.BuilderUploadResult { + resultCode = value + return this + } + + + init { + this.stdOut = stdOut + this.stdErr = stdErr + this.resultCode = resultCode + } + + fun readFrom (input: CodedInputStream): UploadResult.BuilderUploadResult { + stdOut = input.readString(1) + stdErr = input.readString(2) + resultCode = input.readInt32(3) + return this +} + + fun build(): UploadResult { + return UploadResult(stdOut, stdErr, resultCode) + } + + fun parseFieldFrom(input: CodedInputStream): Boolean { + if (input.isAtEnd()) { return false } + val tag = input.readInt32NoTag() + if (tag == 0) { return false } + val fieldNumber = WireFormat.getTagFieldNumber(tag) + val wireType = WireFormat.getTagWireType(tag) + when(fieldNumber) { + 1 -> stdOut = input.readStringNoTag() + 2 -> stdErr = input.readStringNoTag() + 3 -> resultCode = input.readInt32NoTag() + } + return true} + fun parseFrom(input: CodedInputStream): UploadResult.BuilderUploadResult { + while(parseFieldFrom(input)) {} + return this + } + fun getSize(): Int { + var size = 0 + size += WireFormat.getStringSize(1, stdOut) + size += WireFormat.getStringSize(2, stdErr) + size += WireFormat.getInt32Size(3, resultCode) + return size + } + } + + + fun mergeWith (other: UploadResult) { + stdOut = other.stdOut + stdErr = other.stdErr + resultCode = other.resultCode + } + + fun mergeFrom (input: CodedInputStream) { + val builder = UploadResult.BuilderUploadResult() + mergeWith(builder.parseFrom(input).build())} + fun getSize(): Int { + var size = 0 + size += WireFormat.getStringSize(1, stdOut) + size += WireFormat.getStringSize(2, stdErr) + size += WireFormat.getInt32Size(3, resultCode) + return size + } +} + + +class LogMessage private constructor (source: kotlin.String = "", message: ByteArray = ByteArray(0)) { + var source : kotlin.String + private set + + var message : ByteArray + private set + + + init { + this.source = source + this.message = message + } + + fun writeTo (output: CodedOutputStream): Unit { + output.writeString (1, source) + output.writeBytes (2, message) + } + + class BuilderLogMessage constructor (source: kotlin.String = "", message: ByteArray = ByteArray(0)) { + var source : kotlin.String + private set + fun setSource(value: kotlin.String): LogMessage.BuilderLogMessage { + source = value + return this + } + + var message : ByteArray + private set + fun setMessage(value: ByteArray): LogMessage.BuilderLogMessage { + message = value + return this + } + + + init { + this.source = source + this.message = message + } + + fun readFrom (input: CodedInputStream): LogMessage.BuilderLogMessage { + source = input.readString(1) + message = input.readBytes(2) + return this +} + + fun build(): LogMessage { + return LogMessage(source, message) + } + + fun parseFieldFrom(input: CodedInputStream): Boolean { + if (input.isAtEnd()) { return false } + val tag = input.readInt32NoTag() + if (tag == 0) { return false } + val fieldNumber = WireFormat.getTagFieldNumber(tag) + val wireType = WireFormat.getTagWireType(tag) + when(fieldNumber) { + 1 -> source = input.readStringNoTag() + 2 -> message = input.readBytesNoTag() + } + return true} + fun parseFrom(input: CodedInputStream): LogMessage.BuilderLogMessage { + while(parseFieldFrom(input)) {} + return this + } + fun getSize(): Int { + var size = 0 + size += WireFormat.getStringSize(1, source) + size += WireFormat.getBytesSize(2, message) + return size + } + } + + + fun mergeWith (other: LogMessage) { + source = other.source + message.plus(other.message) + } + + fun mergeFrom (input: CodedInputStream) { + val builder = LogMessage.BuilderLogMessage() + mergeWith(builder.parseFrom(input).build())} + fun getSize(): Int { + var size = 0 + size += WireFormat.getStringSize(1, source) + size += WireFormat.getBytesSize(2, message) + return size + } +} + + diff --git a/car_srv/clients/flash/src/main/java/client/Client.kt b/car_srv/clients/flash/src/main/java/client/Client.kt index 182b292fe64..53923dd3c1c 100644 --- a/car_srv/clients/flash/src/main/java/client/Client.kt +++ b/car_srv/clients/flash/src/main/java/client/Client.kt @@ -11,27 +11,34 @@ import java.net.ConnectException /** * Created by user on 7/8/16. */ -object Client { +class Client constructor(host: String, port: Int) { - fun sendRequest(request: HttpRequest, host: String, port: Int):Int { - val group = NioEventLoopGroup() + val host: String + val port: Int + + init { + this.host = host + this.port = port + } + + fun sendRequest(request: HttpRequest) { + val group = NioEventLoopGroup(1) try { - val bootstrap: Bootstrap = Bootstrap() + val bootstrap = Bootstrap() bootstrap.group(group).channel(NioSocketChannel().javaClass).handler(ClientInitializer()) val channelFuture = bootstrap.connect(host, port).sync() val channel = channelFuture.channel() channel.writeAndFlush(request) channel.closeFuture().sync() } catch (e: InterruptedException) { - println("interrupted before request done") - return 2 + ClientHandler.requestResult.code = 2 + ClientHandler.requestResult.errorString = "command execution interrupted" } catch (e: ConnectException) { - println("connection error to $host:$port") - return 1 + ClientHandler.requestResult.code = 1 + ClientHandler.requestResult.errorString = "don't can connect to server ($host:$port)" } finally { group.shutdownGracefully() } - return ClientHandler.requestResult.code } } \ No newline at end of file diff --git a/car_srv/clients/flash/src/main/java/client/ClientHandler.kt b/car_srv/clients/flash/src/main/java/client/ClientHandler.kt index dd06c682657..8738c2f8df2 100644 --- a/car_srv/clients/flash/src/main/java/client/ClientHandler.kt +++ b/car_srv/clients/flash/src/main/java/client/ClientHandler.kt @@ -4,8 +4,6 @@ import com.google.protobuf.InvalidProtocolBufferException import io.netty.channel.ChannelHandlerContext import io.netty.channel.SimpleChannelInboundHandler import io.netty.handler.codec.http.HttpContent -import proto.Carkot -import java.util.* /** * Created by user on 7/8/16. @@ -28,10 +26,10 @@ class ClientHandler : SimpleChannelInboundHandler { val resultStdOut:String val resultStdErr:String try { - val uploadResult: Carkot.UploadResult = Carkot.UploadResult.parseFrom(contentBytes) - resultCode = uploadResult.resultCode - resultStdOut = uploadResult.stdOut - resultStdErr = uploadResult.stdErr +// val uploadResult: Carkot.UploadResult = Carkot.UploadResult.parseFrom(contentBytes) +// resultCode = uploadResult.resultCode +// resultStdOut = uploadResult.stdOut +// resultStdErr = uploadResult.stdErr } catch (e: InvalidProtocolBufferException) { e.printStackTrace() resultStdErr = "" @@ -39,9 +37,9 @@ class ClientHandler : SimpleChannelInboundHandler { resultCode = 2 } synchronized(requestResult, { - requestResult.code = resultCode - requestResult.stdErr = resultStdErr - requestResult.stdOut = resultStdOut +// requestResult.code = resultCode +// requestResult.stdErr = resultStdErr +// requestResult.stdOut = resultStdOut }) ctx.close() } diff --git a/car_srv/clients/flash/src/main/java/proto/Carkot.java b/car_srv/clients/flash/src/main/java/proto/Carkot.java deleted file mode 100644 index eda4e72ad0b..00000000000 --- a/car_srv/clients/flash/src/main/java/proto/Carkot.java +++ /dev/null @@ -1,3175 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: carkot.proto - -package proto; - -public final class Carkot { - private Carkot() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - public interface UploadOrBuilder extends - // @@protoc_insertion_point(interface_extends:carkot.Upload) - com.google.protobuf.MessageOrBuilder { - - /** - *
-     * Firmware data.
-     * 
- * - * optional bytes data = 1; - */ - com.google.protobuf.ByteString getData(); - - /** - *
-     * Firmware load address (string, to avoid 64-bit woes).
-     * 
- * - * optional string base = 2; - */ - java.lang.String getBase(); - /** - *
-     * Firmware load address (string, to avoid 64-bit woes).
-     * 
- * - * optional string base = 2; - */ - com.google.protobuf.ByteString - getBaseBytes(); - - /** - *
-     * Method of firmware upload.
-     * 
- * - * optional .carkot.Upload.Method method = 3; - */ - boolean hasMethod(); - /** - *
-     * Method of firmware upload.
-     * 
- * - * optional .carkot.Upload.Method method = 3; - */ - proto.Carkot.Upload.Method getMethod(); - /** - *
-     * Method of firmware upload.
-     * 
- * - * optional .carkot.Upload.Method method = 3; - */ - proto.Carkot.Upload.MethodOrBuilder getMethodOrBuilder(); - } - /** - * Protobuf type {@code carkot.Upload} - */ - public static final class Upload extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:carkot.Upload) - UploadOrBuilder { - // Use Upload.newBuilder() to construct. - private Upload(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Upload() { - data_ = com.google.protobuf.ByteString.EMPTY; - base_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Upload( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - - data_ = input.readBytes(); - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - base_ = s; - break; - } - case 26: { - proto.Carkot.Upload.Method.Builder subBuilder = null; - if (method_ != null) { - subBuilder = method_.toBuilder(); - } - method_ = input.readMessage(proto.Carkot.Upload.Method.parser(), extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(method_); - method_ = subBuilder.buildPartial(); - } - - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return proto.Carkot.internal_static_carkot_Upload_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return proto.Carkot.internal_static_carkot_Upload_fieldAccessorTable - .ensureFieldAccessorsInitialized( - proto.Carkot.Upload.class, proto.Carkot.Upload.Builder.class); - } - - public interface MethodOrBuilder extends - // @@protoc_insertion_point(interface_extends:carkot.Upload.Method) - com.google.protobuf.MessageOrBuilder { - - /** - *
-       * Type of upload method.
-       * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - int getTypeValue(); - /** - *
-       * Type of upload method.
-       * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - proto.Carkot.Upload.Method.TYPE getType(); - - /** - *
-       * Upload port.
-       * 
- * - * optional string port = 2; - */ - java.lang.String getPort(); - /** - *
-       * Upload port.
-       * 
- * - * optional string port = 2; - */ - com.google.protobuf.ByteString - getPortBytes(); - - /** - *
-       * Device address, smth like 8087:0ABA.
-       * 
- * - * optional string device = 3; - */ - java.lang.String getDevice(); - /** - *
-       * Device address, smth like 8087:0ABA.
-       * 
- * - * optional string device = 3; - */ - com.google.protobuf.ByteString - getDeviceBytes(); - - /** - *
-       * Additional programmator-specific arguments.
-       * 
- * - * repeated string arguments = 4; - */ - com.google.protobuf.ProtocolStringList - getArgumentsList(); - /** - *
-       * Additional programmator-specific arguments.
-       * 
- * - * repeated string arguments = 4; - */ - int getArgumentsCount(); - /** - *
-       * Additional programmator-specific arguments.
-       * 
- * - * repeated string arguments = 4; - */ - java.lang.String getArguments(int index); - /** - *
-       * Additional programmator-specific arguments.
-       * 
- * - * repeated string arguments = 4; - */ - com.google.protobuf.ByteString - getArgumentsBytes(int index); - } - /** - * Protobuf type {@code carkot.Upload.Method} - */ - public static final class Method extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:carkot.Upload.Method) - MethodOrBuilder { - // Use Method.newBuilder() to construct. - private Method(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Method() { - type_ = 0; - port_ = ""; - device_ = ""; - arguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Method( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 8: { - int rawValue = input.readEnum(); - - type_ = rawValue; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - port_ = s; - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); - - device_ = s; - break; - } - case 34: { - java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - arguments_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000008; - } - arguments_.add(s); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - arguments_ = arguments_.getUnmodifiableView(); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return proto.Carkot.internal_static_carkot_Upload_Method_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return proto.Carkot.internal_static_carkot_Upload_Method_fieldAccessorTable - .ensureFieldAccessorsInitialized( - proto.Carkot.Upload.Method.class, proto.Carkot.Upload.Method.Builder.class); - } - - /** - * Protobuf enum {@code carkot.Upload.Method.TYPE} - */ - public enum TYPE - implements com.google.protobuf.ProtocolMessageEnum { - /** - * DFU = 0; - */ - DFU(0), - /** - * STLINK = 1; - */ - STLINK(1), - UNRECOGNIZED(-1), - ; - - /** - * DFU = 0; - */ - public static final int DFU_VALUE = 0; - /** - * STLINK = 1; - */ - public static final int STLINK_VALUE = 1; - - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static TYPE valueOf(int value) { - return forNumber(value); - } - - public static TYPE forNumber(int value) { - switch (value) { - case 0: return DFU; - case 1: return STLINK; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static final com.google.protobuf.Internal.EnumLiteMap< - TYPE> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public TYPE findValueByNumber(int number) { - return TYPE.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(ordinal()); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return proto.Carkot.Upload.Method.getDescriptor().getEnumTypes().get(0); - } - - private static final TYPE[] VALUES = values(); - - public static TYPE valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private TYPE(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:carkot.Upload.Method.TYPE) - } - - private int bitField0_; - public static final int TYPE_FIELD_NUMBER = 1; - private int type_; - /** - *
-       * Type of upload method.
-       * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - public int getTypeValue() { - return type_; - } - /** - *
-       * Type of upload method.
-       * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - public proto.Carkot.Upload.Method.TYPE getType() { - proto.Carkot.Upload.Method.TYPE result = proto.Carkot.Upload.Method.TYPE.forNumber(type_); - return result == null ? proto.Carkot.Upload.Method.TYPE.UNRECOGNIZED : result; - } - - public static final int PORT_FIELD_NUMBER = 2; - private volatile java.lang.Object port_; - /** - *
-       * Upload port.
-       * 
- * - * optional string port = 2; - */ - public java.lang.String getPort() { - java.lang.Object ref = port_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - port_ = s; - return s; - } - } - /** - *
-       * Upload port.
-       * 
- * - * optional string port = 2; - */ - public com.google.protobuf.ByteString - getPortBytes() { - java.lang.Object ref = port_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - port_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DEVICE_FIELD_NUMBER = 3; - private volatile java.lang.Object device_; - /** - *
-       * Device address, smth like 8087:0ABA.
-       * 
- * - * optional string device = 3; - */ - public java.lang.String getDevice() { - java.lang.Object ref = device_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - device_ = s; - return s; - } - } - /** - *
-       * Device address, smth like 8087:0ABA.
-       * 
- * - * optional string device = 3; - */ - public com.google.protobuf.ByteString - getDeviceBytes() { - java.lang.Object ref = device_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - device_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ARGUMENTS_FIELD_NUMBER = 4; - private com.google.protobuf.LazyStringList arguments_; - /** - *
-       * Additional programmator-specific arguments.
-       * 
- * - * repeated string arguments = 4; - */ - public com.google.protobuf.ProtocolStringList - getArgumentsList() { - return arguments_; - } - /** - *
-       * Additional programmator-specific arguments.
-       * 
- * - * repeated string arguments = 4; - */ - public int getArgumentsCount() { - return arguments_.size(); - } - /** - *
-       * Additional programmator-specific arguments.
-       * 
- * - * repeated string arguments = 4; - */ - public java.lang.String getArguments(int index) { - return arguments_.get(index); - } - /** - *
-       * Additional programmator-specific arguments.
-       * 
- * - * repeated string arguments = 4; - */ - public com.google.protobuf.ByteString - getArgumentsBytes(int index) { - return arguments_.getByteString(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (type_ != proto.Carkot.Upload.Method.TYPE.DFU.getNumber()) { - output.writeEnum(1, type_); - } - if (!getPortBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, port_); - } - if (!getDeviceBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, device_); - } - for (int i = 0; i < arguments_.size(); i++) { - com.google.protobuf.GeneratedMessage.writeString(output, 4, arguments_.getRaw(i)); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (type_ != proto.Carkot.Upload.Method.TYPE.DFU.getNumber()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(1, type_); - } - if (!getPortBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, port_); - } - if (!getDeviceBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, device_); - } - { - int dataSize = 0; - for (int i = 0; i < arguments_.size(); i++) { - dataSize += computeStringSizeNoTag(arguments_.getRaw(i)); - } - size += dataSize; - size += 1 * getArgumentsList().size(); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static proto.Carkot.Upload.Method parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static proto.Carkot.Upload.Method parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static proto.Carkot.Upload.Method parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static proto.Carkot.Upload.Method parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static proto.Carkot.Upload.Method parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static proto.Carkot.Upload.Method parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static proto.Carkot.Upload.Method parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input); - } - public static proto.Carkot.Upload.Method parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static proto.Carkot.Upload.Method parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static proto.Carkot.Upload.Method parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(proto.Carkot.Upload.Method prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code carkot.Upload.Method} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:carkot.Upload.Method) - proto.Carkot.Upload.MethodOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return proto.Carkot.internal_static_carkot_Upload_Method_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return proto.Carkot.internal_static_carkot_Upload_Method_fieldAccessorTable - .ensureFieldAccessorsInitialized( - proto.Carkot.Upload.Method.class, proto.Carkot.Upload.Method.Builder.class); - } - - // Construct using proto.Carkot.Upload.Method.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - type_ = 0; - - port_ = ""; - - device_ = ""; - - arguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000008); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return proto.Carkot.internal_static_carkot_Upload_Method_descriptor; - } - - public proto.Carkot.Upload.Method getDefaultInstanceForType() { - return proto.Carkot.Upload.Method.getDefaultInstance(); - } - - public proto.Carkot.Upload.Method build() { - proto.Carkot.Upload.Method result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public proto.Carkot.Upload.Method buildPartial() { - proto.Carkot.Upload.Method result = new proto.Carkot.Upload.Method(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.type_ = type_; - result.port_ = port_; - result.device_ = device_; - if (((bitField0_ & 0x00000008) == 0x00000008)) { - arguments_ = arguments_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000008); - } - result.arguments_ = arguments_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof proto.Carkot.Upload.Method) { - return mergeFrom((proto.Carkot.Upload.Method)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(proto.Carkot.Upload.Method other) { - if (other == proto.Carkot.Upload.Method.getDefaultInstance()) return this; - if (other.type_ != 0) { - setTypeValue(other.getTypeValue()); - } - if (!other.getPort().isEmpty()) { - port_ = other.port_; - onChanged(); - } - if (!other.getDevice().isEmpty()) { - device_ = other.device_; - onChanged(); - } - if (!other.arguments_.isEmpty()) { - if (arguments_.isEmpty()) { - arguments_ = other.arguments_; - bitField0_ = (bitField0_ & ~0x00000008); - } else { - ensureArgumentsIsMutable(); - arguments_.addAll(other.arguments_); - } - onChanged(); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - proto.Carkot.Upload.Method parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (proto.Carkot.Upload.Method) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private int type_ = 0; - /** - *
-         * Type of upload method.
-         * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - public int getTypeValue() { - return type_; - } - /** - *
-         * Type of upload method.
-         * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - public Builder setTypeValue(int value) { - type_ = value; - onChanged(); - return this; - } - /** - *
-         * Type of upload method.
-         * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - public proto.Carkot.Upload.Method.TYPE getType() { - proto.Carkot.Upload.Method.TYPE result = proto.Carkot.Upload.Method.TYPE.forNumber(type_); - return result == null ? proto.Carkot.Upload.Method.TYPE.UNRECOGNIZED : result; - } - /** - *
-         * Type of upload method.
-         * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - public Builder setType(proto.Carkot.Upload.Method.TYPE value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value.getNumber(); - onChanged(); - return this; - } - /** - *
-         * Type of upload method.
-         * 
- * - * optional .carkot.Upload.Method.TYPE type = 1; - */ - public Builder clearType() { - - type_ = 0; - onChanged(); - return this; - } - - private java.lang.Object port_ = ""; - /** - *
-         * Upload port.
-         * 
- * - * optional string port = 2; - */ - public java.lang.String getPort() { - java.lang.Object ref = port_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - port_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-         * Upload port.
-         * 
- * - * optional string port = 2; - */ - public com.google.protobuf.ByteString - getPortBytes() { - java.lang.Object ref = port_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - port_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-         * Upload port.
-         * 
- * - * optional string port = 2; - */ - public Builder setPort( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - port_ = value; - onChanged(); - return this; - } - /** - *
-         * Upload port.
-         * 
- * - * optional string port = 2; - */ - public Builder clearPort() { - - port_ = getDefaultInstance().getPort(); - onChanged(); - return this; - } - /** - *
-         * Upload port.
-         * 
- * - * optional string port = 2; - */ - public Builder setPortBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - port_ = value; - onChanged(); - return this; - } - - private java.lang.Object device_ = ""; - /** - *
-         * Device address, smth like 8087:0ABA.
-         * 
- * - * optional string device = 3; - */ - public java.lang.String getDevice() { - java.lang.Object ref = device_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - device_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-         * Device address, smth like 8087:0ABA.
-         * 
- * - * optional string device = 3; - */ - public com.google.protobuf.ByteString - getDeviceBytes() { - java.lang.Object ref = device_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - device_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-         * Device address, smth like 8087:0ABA.
-         * 
- * - * optional string device = 3; - */ - public Builder setDevice( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - device_ = value; - onChanged(); - return this; - } - /** - *
-         * Device address, smth like 8087:0ABA.
-         * 
- * - * optional string device = 3; - */ - public Builder clearDevice() { - - device_ = getDefaultInstance().getDevice(); - onChanged(); - return this; - } - /** - *
-         * Device address, smth like 8087:0ABA.
-         * 
- * - * optional string device = 3; - */ - public Builder setDeviceBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - device_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.LazyStringList arguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureArgumentsIsMutable() { - if (!((bitField0_ & 0x00000008) == 0x00000008)) { - arguments_ = new com.google.protobuf.LazyStringArrayList(arguments_); - bitField0_ |= 0x00000008; - } - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public com.google.protobuf.ProtocolStringList - getArgumentsList() { - return arguments_.getUnmodifiableView(); - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public int getArgumentsCount() { - return arguments_.size(); - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public java.lang.String getArguments(int index) { - return arguments_.get(index); - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public com.google.protobuf.ByteString - getArgumentsBytes(int index) { - return arguments_.getByteString(index); - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public Builder setArguments( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureArgumentsIsMutable(); - arguments_.set(index, value); - onChanged(); - return this; - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public Builder addArguments( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureArgumentsIsMutable(); - arguments_.add(value); - onChanged(); - return this; - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public Builder addAllArguments( - java.lang.Iterable values) { - ensureArgumentsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, arguments_); - onChanged(); - return this; - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public Builder clearArguments() { - arguments_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000008); - onChanged(); - return this; - } - /** - *
-         * Additional programmator-specific arguments.
-         * 
- * - * repeated string arguments = 4; - */ - public Builder addArgumentsBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - ensureArgumentsIsMutable(); - arguments_.add(value); - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:carkot.Upload.Method) - } - - // @@protoc_insertion_point(class_scope:carkot.Upload.Method) - private static final proto.Carkot.Upload.Method DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new proto.Carkot.Upload.Method(); - } - - public static proto.Carkot.Upload.Method getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Method parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Method(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public proto.Carkot.Upload.Method getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public static final int DATA_FIELD_NUMBER = 1; - private com.google.protobuf.ByteString data_; - /** - *
-     * Firmware data.
-     * 
- * - * optional bytes data = 1; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - public static final int BASE_FIELD_NUMBER = 2; - private volatile java.lang.Object base_; - /** - *
-     * Firmware load address (string, to avoid 64-bit woes).
-     * 
- * - * optional string base = 2; - */ - public java.lang.String getBase() { - java.lang.Object ref = base_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - base_ = s; - return s; - } - } - /** - *
-     * Firmware load address (string, to avoid 64-bit woes).
-     * 
- * - * optional string base = 2; - */ - public com.google.protobuf.ByteString - getBaseBytes() { - java.lang.Object ref = base_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - base_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int METHOD_FIELD_NUMBER = 3; - private proto.Carkot.Upload.Method method_; - /** - *
-     * Method of firmware upload.
-     * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public boolean hasMethod() { - return method_ != null; - } - /** - *
-     * Method of firmware upload.
-     * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public proto.Carkot.Upload.Method getMethod() { - return method_ == null ? proto.Carkot.Upload.Method.getDefaultInstance() : method_; - } - /** - *
-     * Method of firmware upload.
-     * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public proto.Carkot.Upload.MethodOrBuilder getMethodOrBuilder() { - return getMethod(); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!data_.isEmpty()) { - output.writeBytes(1, data_); - } - if (!getBaseBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, base_); - } - if (method_ != null) { - output.writeMessage(3, getMethod()); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!data_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, data_); - } - if (!getBaseBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, base_); - } - if (method_ != null) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, getMethod()); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static proto.Carkot.Upload parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static proto.Carkot.Upload parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static proto.Carkot.Upload parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static proto.Carkot.Upload parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static proto.Carkot.Upload parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static proto.Carkot.Upload parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static proto.Carkot.Upload parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input); - } - public static proto.Carkot.Upload parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static proto.Carkot.Upload parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static proto.Carkot.Upload parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(proto.Carkot.Upload prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code carkot.Upload} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:carkot.Upload) - proto.Carkot.UploadOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return proto.Carkot.internal_static_carkot_Upload_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return proto.Carkot.internal_static_carkot_Upload_fieldAccessorTable - .ensureFieldAccessorsInitialized( - proto.Carkot.Upload.class, proto.Carkot.Upload.Builder.class); - } - - // Construct using proto.Carkot.Upload.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - data_ = com.google.protobuf.ByteString.EMPTY; - - base_ = ""; - - if (methodBuilder_ == null) { - method_ = null; - } else { - method_ = null; - methodBuilder_ = null; - } - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return proto.Carkot.internal_static_carkot_Upload_descriptor; - } - - public proto.Carkot.Upload getDefaultInstanceForType() { - return proto.Carkot.Upload.getDefaultInstance(); - } - - public proto.Carkot.Upload build() { - proto.Carkot.Upload result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public proto.Carkot.Upload buildPartial() { - proto.Carkot.Upload result = new proto.Carkot.Upload(this); - result.data_ = data_; - result.base_ = base_; - if (methodBuilder_ == null) { - result.method_ = method_; - } else { - result.method_ = methodBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof proto.Carkot.Upload) { - return mergeFrom((proto.Carkot.Upload)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(proto.Carkot.Upload other) { - if (other == proto.Carkot.Upload.getDefaultInstance()) return this; - if (other.getData() != com.google.protobuf.ByteString.EMPTY) { - setData(other.getData()); - } - if (!other.getBase().isEmpty()) { - base_ = other.base_; - onChanged(); - } - if (other.hasMethod()) { - mergeMethod(other.getMethod()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - proto.Carkot.Upload parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (proto.Carkot.Upload) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; - /** - *
-       * Firmware data.
-       * 
- * - * optional bytes data = 1; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - /** - *
-       * Firmware data.
-       * 
- * - * optional bytes data = 1; - */ - public Builder setData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - data_ = value; - onChanged(); - return this; - } - /** - *
-       * Firmware data.
-       * 
- * - * optional bytes data = 1; - */ - public Builder clearData() { - - data_ = getDefaultInstance().getData(); - onChanged(); - return this; - } - - private java.lang.Object base_ = ""; - /** - *
-       * Firmware load address (string, to avoid 64-bit woes).
-       * 
- * - * optional string base = 2; - */ - public java.lang.String getBase() { - java.lang.Object ref = base_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - base_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - *
-       * Firmware load address (string, to avoid 64-bit woes).
-       * 
- * - * optional string base = 2; - */ - public com.google.protobuf.ByteString - getBaseBytes() { - java.lang.Object ref = base_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - base_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - *
-       * Firmware load address (string, to avoid 64-bit woes).
-       * 
- * - * optional string base = 2; - */ - public Builder setBase( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - base_ = value; - onChanged(); - return this; - } - /** - *
-       * Firmware load address (string, to avoid 64-bit woes).
-       * 
- * - * optional string base = 2; - */ - public Builder clearBase() { - - base_ = getDefaultInstance().getBase(); - onChanged(); - return this; - } - /** - *
-       * Firmware load address (string, to avoid 64-bit woes).
-       * 
- * - * optional string base = 2; - */ - public Builder setBaseBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - base_ = value; - onChanged(); - return this; - } - - private proto.Carkot.Upload.Method method_ = null; - private com.google.protobuf.SingleFieldBuilder< - proto.Carkot.Upload.Method, proto.Carkot.Upload.Method.Builder, proto.Carkot.Upload.MethodOrBuilder> methodBuilder_; - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public boolean hasMethod() { - return methodBuilder_ != null || method_ != null; - } - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public proto.Carkot.Upload.Method getMethod() { - if (methodBuilder_ == null) { - return method_ == null ? proto.Carkot.Upload.Method.getDefaultInstance() : method_; - } else { - return methodBuilder_.getMessage(); - } - } - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public Builder setMethod(proto.Carkot.Upload.Method value) { - if (methodBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - method_ = value; - onChanged(); - } else { - methodBuilder_.setMessage(value); - } - - return this; - } - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public Builder setMethod( - proto.Carkot.Upload.Method.Builder builderForValue) { - if (methodBuilder_ == null) { - method_ = builderForValue.build(); - onChanged(); - } else { - methodBuilder_.setMessage(builderForValue.build()); - } - - return this; - } - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public Builder mergeMethod(proto.Carkot.Upload.Method value) { - if (methodBuilder_ == null) { - if (method_ != null) { - method_ = - proto.Carkot.Upload.Method.newBuilder(method_).mergeFrom(value).buildPartial(); - } else { - method_ = value; - } - onChanged(); - } else { - methodBuilder_.mergeFrom(value); - } - - return this; - } - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public Builder clearMethod() { - if (methodBuilder_ == null) { - method_ = null; - onChanged(); - } else { - method_ = null; - methodBuilder_ = null; - } - - return this; - } - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public proto.Carkot.Upload.Method.Builder getMethodBuilder() { - - onChanged(); - return getMethodFieldBuilder().getBuilder(); - } - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - public proto.Carkot.Upload.MethodOrBuilder getMethodOrBuilder() { - if (methodBuilder_ != null) { - return methodBuilder_.getMessageOrBuilder(); - } else { - return method_ == null ? - proto.Carkot.Upload.Method.getDefaultInstance() : method_; - } - } - /** - *
-       * Method of firmware upload.
-       * 
- * - * optional .carkot.Upload.Method method = 3; - */ - private com.google.protobuf.SingleFieldBuilder< - proto.Carkot.Upload.Method, proto.Carkot.Upload.Method.Builder, proto.Carkot.Upload.MethodOrBuilder> - getMethodFieldBuilder() { - if (methodBuilder_ == null) { - methodBuilder_ = new com.google.protobuf.SingleFieldBuilder< - proto.Carkot.Upload.Method, proto.Carkot.Upload.Method.Builder, proto.Carkot.Upload.MethodOrBuilder>( - getMethod(), - getParentForChildren(), - isClean()); - method_ = null; - } - return methodBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:carkot.Upload) - } - - // @@protoc_insertion_point(class_scope:carkot.Upload) - private static final proto.Carkot.Upload DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new proto.Carkot.Upload(); - } - - public static proto.Carkot.Upload getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Upload parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Upload(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public proto.Carkot.Upload getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface UploadResultOrBuilder extends - // @@protoc_insertion_point(interface_extends:carkot.UploadResult) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string stdOut = 1; - */ - java.lang.String getStdOut(); - /** - * optional string stdOut = 1; - */ - com.google.protobuf.ByteString - getStdOutBytes(); - - /** - * optional string stdErr = 2; - */ - java.lang.String getStdErr(); - /** - * optional string stdErr = 2; - */ - com.google.protobuf.ByteString - getStdErrBytes(); - - /** - * optional int32 resultCode = 3; - */ - int getResultCode(); - } - /** - * Protobuf type {@code carkot.UploadResult} - */ - public static final class UploadResult extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:carkot.UploadResult) - UploadResultOrBuilder { - // Use UploadResult.newBuilder() to construct. - private UploadResult(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private UploadResult() { - stdOut_ = ""; - stdErr_ = ""; - resultCode_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private UploadResult( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - stdOut_ = s; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - stdErr_ = s; - break; - } - case 24: { - - resultCode_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return proto.Carkot.internal_static_carkot_UploadResult_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return proto.Carkot.internal_static_carkot_UploadResult_fieldAccessorTable - .ensureFieldAccessorsInitialized( - proto.Carkot.UploadResult.class, proto.Carkot.UploadResult.Builder.class); - } - - public static final int STDOUT_FIELD_NUMBER = 1; - private volatile java.lang.Object stdOut_; - /** - * optional string stdOut = 1; - */ - public java.lang.String getStdOut() { - java.lang.Object ref = stdOut_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - stdOut_ = s; - return s; - } - } - /** - * optional string stdOut = 1; - */ - public com.google.protobuf.ByteString - getStdOutBytes() { - java.lang.Object ref = stdOut_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - stdOut_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int STDERR_FIELD_NUMBER = 2; - private volatile java.lang.Object stdErr_; - /** - * optional string stdErr = 2; - */ - public java.lang.String getStdErr() { - java.lang.Object ref = stdErr_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - stdErr_ = s; - return s; - } - } - /** - * optional string stdErr = 2; - */ - public com.google.protobuf.ByteString - getStdErrBytes() { - java.lang.Object ref = stdErr_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - stdErr_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RESULTCODE_FIELD_NUMBER = 3; - private int resultCode_; - /** - * optional int32 resultCode = 3; - */ - public int getResultCode() { - return resultCode_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getStdOutBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, stdOut_); - } - if (!getStdErrBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, stdErr_); - } - if (resultCode_ != 0) { - output.writeInt32(3, resultCode_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getStdOutBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, stdOut_); - } - if (!getStdErrBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, stdErr_); - } - if (resultCode_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, resultCode_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static proto.Carkot.UploadResult parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static proto.Carkot.UploadResult parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static proto.Carkot.UploadResult parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static proto.Carkot.UploadResult parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static proto.Carkot.UploadResult parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static proto.Carkot.UploadResult parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static proto.Carkot.UploadResult parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input); - } - public static proto.Carkot.UploadResult parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static proto.Carkot.UploadResult parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static proto.Carkot.UploadResult parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(proto.Carkot.UploadResult prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code carkot.UploadResult} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:carkot.UploadResult) - proto.Carkot.UploadResultOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return proto.Carkot.internal_static_carkot_UploadResult_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return proto.Carkot.internal_static_carkot_UploadResult_fieldAccessorTable - .ensureFieldAccessorsInitialized( - proto.Carkot.UploadResult.class, proto.Carkot.UploadResult.Builder.class); - } - - // Construct using proto.Carkot.UploadResult.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - stdOut_ = ""; - - stdErr_ = ""; - - resultCode_ = 0; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return proto.Carkot.internal_static_carkot_UploadResult_descriptor; - } - - public proto.Carkot.UploadResult getDefaultInstanceForType() { - return proto.Carkot.UploadResult.getDefaultInstance(); - } - - public proto.Carkot.UploadResult build() { - proto.Carkot.UploadResult result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public proto.Carkot.UploadResult buildPartial() { - proto.Carkot.UploadResult result = new proto.Carkot.UploadResult(this); - result.stdOut_ = stdOut_; - result.stdErr_ = stdErr_; - result.resultCode_ = resultCode_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof proto.Carkot.UploadResult) { - return mergeFrom((proto.Carkot.UploadResult)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(proto.Carkot.UploadResult other) { - if (other == proto.Carkot.UploadResult.getDefaultInstance()) return this; - if (!other.getStdOut().isEmpty()) { - stdOut_ = other.stdOut_; - onChanged(); - } - if (!other.getStdErr().isEmpty()) { - stdErr_ = other.stdErr_; - onChanged(); - } - if (other.getResultCode() != 0) { - setResultCode(other.getResultCode()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - proto.Carkot.UploadResult parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (proto.Carkot.UploadResult) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object stdOut_ = ""; - /** - * optional string stdOut = 1; - */ - public java.lang.String getStdOut() { - java.lang.Object ref = stdOut_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - stdOut_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string stdOut = 1; - */ - public com.google.protobuf.ByteString - getStdOutBytes() { - java.lang.Object ref = stdOut_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - stdOut_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string stdOut = 1; - */ - public Builder setStdOut( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - stdOut_ = value; - onChanged(); - return this; - } - /** - * optional string stdOut = 1; - */ - public Builder clearStdOut() { - - stdOut_ = getDefaultInstance().getStdOut(); - onChanged(); - return this; - } - /** - * optional string stdOut = 1; - */ - public Builder setStdOutBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - stdOut_ = value; - onChanged(); - return this; - } - - private java.lang.Object stdErr_ = ""; - /** - * optional string stdErr = 2; - */ - public java.lang.String getStdErr() { - java.lang.Object ref = stdErr_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - stdErr_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string stdErr = 2; - */ - public com.google.protobuf.ByteString - getStdErrBytes() { - java.lang.Object ref = stdErr_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - stdErr_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string stdErr = 2; - */ - public Builder setStdErr( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - stdErr_ = value; - onChanged(); - return this; - } - /** - * optional string stdErr = 2; - */ - public Builder clearStdErr() { - - stdErr_ = getDefaultInstance().getStdErr(); - onChanged(); - return this; - } - /** - * optional string stdErr = 2; - */ - public Builder setStdErrBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - stdErr_ = value; - onChanged(); - return this; - } - - private int resultCode_ ; - /** - * optional int32 resultCode = 3; - */ - public int getResultCode() { - return resultCode_; - } - /** - * optional int32 resultCode = 3; - */ - public Builder setResultCode(int value) { - - resultCode_ = value; - onChanged(); - return this; - } - /** - * optional int32 resultCode = 3; - */ - public Builder clearResultCode() { - - resultCode_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:carkot.UploadResult) - } - - // @@protoc_insertion_point(class_scope:carkot.UploadResult) - private static final proto.Carkot.UploadResult DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new proto.Carkot.UploadResult(); - } - - public static proto.Carkot.UploadResult getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public UploadResult parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new UploadResult(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public proto.Carkot.UploadResult getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface LogMessageOrBuilder extends - // @@protoc_insertion_point(interface_extends:carkot.LogMessage) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string source = 1; - */ - java.lang.String getSource(); - /** - * optional string source = 1; - */ - com.google.protobuf.ByteString - getSourceBytes(); - - /** - * optional bytes message = 2; - */ - com.google.protobuf.ByteString getMessage(); - } - /** - * Protobuf type {@code carkot.LogMessage} - */ - public static final class LogMessage extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:carkot.LogMessage) - LogMessageOrBuilder { - // Use LogMessage.newBuilder() to construct. - private LogMessage(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private LogMessage() { - source_ = ""; - message_ = com.google.protobuf.ByteString.EMPTY; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private LogMessage( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - source_ = s; - break; - } - case 18: { - - message_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return proto.Carkot.internal_static_carkot_LogMessage_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return proto.Carkot.internal_static_carkot_LogMessage_fieldAccessorTable - .ensureFieldAccessorsInitialized( - proto.Carkot.LogMessage.class, proto.Carkot.LogMessage.Builder.class); - } - - public static final int SOURCE_FIELD_NUMBER = 1; - private volatile java.lang.Object source_; - /** - * optional string source = 1; - */ - public java.lang.String getSource() { - java.lang.Object ref = source_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - source_ = s; - return s; - } - } - /** - * optional string source = 1; - */ - public com.google.protobuf.ByteString - getSourceBytes() { - java.lang.Object ref = source_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - source_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int MESSAGE_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString message_; - /** - * optional bytes message = 2; - */ - public com.google.protobuf.ByteString getMessage() { - return message_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getSourceBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, source_); - } - if (!message_.isEmpty()) { - output.writeBytes(2, message_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getSourceBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, source_); - } - if (!message_.isEmpty()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, message_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static proto.Carkot.LogMessage parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static proto.Carkot.LogMessage parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static proto.Carkot.LogMessage parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static proto.Carkot.LogMessage parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static proto.Carkot.LogMessage parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static proto.Carkot.LogMessage parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static proto.Carkot.LogMessage parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input); - } - public static proto.Carkot.LogMessage parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static proto.Carkot.LogMessage parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static proto.Carkot.LogMessage parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(proto.Carkot.LogMessage prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code carkot.LogMessage} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:carkot.LogMessage) - proto.Carkot.LogMessageOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return proto.Carkot.internal_static_carkot_LogMessage_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return proto.Carkot.internal_static_carkot_LogMessage_fieldAccessorTable - .ensureFieldAccessorsInitialized( - proto.Carkot.LogMessage.class, proto.Carkot.LogMessage.Builder.class); - } - - // Construct using proto.Carkot.LogMessage.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - source_ = ""; - - message_ = com.google.protobuf.ByteString.EMPTY; - - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return proto.Carkot.internal_static_carkot_LogMessage_descriptor; - } - - public proto.Carkot.LogMessage getDefaultInstanceForType() { - return proto.Carkot.LogMessage.getDefaultInstance(); - } - - public proto.Carkot.LogMessage build() { - proto.Carkot.LogMessage result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public proto.Carkot.LogMessage buildPartial() { - proto.Carkot.LogMessage result = new proto.Carkot.LogMessage(this); - result.source_ = source_; - result.message_ = message_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof proto.Carkot.LogMessage) { - return mergeFrom((proto.Carkot.LogMessage)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(proto.Carkot.LogMessage other) { - if (other == proto.Carkot.LogMessage.getDefaultInstance()) return this; - if (!other.getSource().isEmpty()) { - source_ = other.source_; - onChanged(); - } - if (other.getMessage() != com.google.protobuf.ByteString.EMPTY) { - setMessage(other.getMessage()); - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - proto.Carkot.LogMessage parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (proto.Carkot.LogMessage) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object source_ = ""; - /** - * optional string source = 1; - */ - public java.lang.String getSource() { - java.lang.Object ref = source_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - source_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string source = 1; - */ - public com.google.protobuf.ByteString - getSourceBytes() { - java.lang.Object ref = source_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - source_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string source = 1; - */ - public Builder setSource( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - source_ = value; - onChanged(); - return this; - } - /** - * optional string source = 1; - */ - public Builder clearSource() { - - source_ = getDefaultInstance().getSource(); - onChanged(); - return this; - } - /** - * optional string source = 1; - */ - public Builder setSourceBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - source_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.ByteString message_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes message = 2; - */ - public com.google.protobuf.ByteString getMessage() { - return message_; - } - /** - * optional bytes message = 2; - */ - public Builder setMessage(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - - message_ = value; - onChanged(); - return this; - } - /** - * optional bytes message = 2; - */ - public Builder clearMessage() { - - message_ = getDefaultInstance().getMessage(); - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:carkot.LogMessage) - } - - // @@protoc_insertion_point(class_scope:carkot.LogMessage) - private static final proto.Carkot.LogMessage DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new proto.Carkot.LogMessage(); - } - - public static proto.Carkot.LogMessage getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public LogMessage parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new LogMessage(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public proto.Carkot.LogMessage getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_carkot_Upload_descriptor; - private static final - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_carkot_Upload_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_carkot_Upload_Method_descriptor; - private static final - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_carkot_Upload_Method_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_carkot_UploadResult_descriptor; - private static final - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_carkot_UploadResult_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_carkot_LogMessage_descriptor; - private static final - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_carkot_LogMessage_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\014carkot.proto\022\006carkot\"\316\001\n\006Upload\022\014\n\004dat" + - "a\030\001 \001(\014\022\014\n\004base\030\002 \001(\t\022%\n\006method\030\003 \001(\0132\025." + - "carkot.Upload.Method\032\200\001\n\006Method\022(\n\004type\030" + - "\001 \001(\0162\032.carkot.Upload.Method.TYPE\022\014\n\004por" + - "t\030\002 \001(\t\022\016\n\006device\030\003 \001(\t\022\021\n\targuments\030\004 \003" + - "(\t\"\033\n\004TYPE\022\007\n\003DFU\020\000\022\n\n\006STLINK\020\001\"B\n\014Uploa" + - "dResult\022\016\n\006stdOut\030\001 \001(\t\022\016\n\006stdErr\030\002 \001(\t\022" + - "\022\n\nresultCode\030\003 \001(\005\"-\n\nLogMessage\022\016\n\006sou" + - "rce\030\001 \001(\t\022\017\n\007message\030\002 \001(\014B\017\n\005protoB\006Car" + - "kotb\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_carkot_Upload_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_carkot_Upload_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_carkot_Upload_descriptor, - new java.lang.String[] { "Data", "Base", "Method", }); - internal_static_carkot_Upload_Method_descriptor = - internal_static_carkot_Upload_descriptor.getNestedTypes().get(0); - internal_static_carkot_Upload_Method_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_carkot_Upload_Method_descriptor, - new java.lang.String[] { "Type", "Port", "Device", "Arguments", }); - internal_static_carkot_UploadResult_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_carkot_UploadResult_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_carkot_UploadResult_descriptor, - new java.lang.String[] { "StdOut", "StdErr", "ResultCode", }); - internal_static_carkot_LogMessage_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_carkot_LogMessage_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_carkot_LogMessage_descriptor, - new java.lang.String[] { "Source", "Message", }); - } - - // @@protoc_insertion_point(outer_class_scope) -}