text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/websecurityscanner/v1alpha/finding_addon.proto

package com.google.cloud.websecurityscanner.v1alpha;

/**
 *
 *
 *

 * Information reported for an XSS.
 *

 *
 * Protobuf type {@code google.cloud.websecurityscanner.v1alpha.Xss}
 */
public final class Xss extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.websecurityscanner.v1alpha.Xss)
    XssOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use Xss.newBuilder() to construct.
  private Xss(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private Xss() {
    stackTraces_ = com.google.protobuf.LazyStringArrayList.EMPTY;
    errorMessage_ = "";
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new Xss();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.websecurityscanner.v1alpha.FindingAddonProto
        .internal_static_google_cloud_websecurityscanner_v1alpha_Xss_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.websecurityscanner.v1alpha.FindingAddonProto
        .internal_static_google_cloud_websecurityscanner_v1alpha_Xss_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.websecurityscanner.v1alpha.Xss.class,
            com.google.cloud.websecurityscanner.v1alpha.Xss.Builder.class);
  }

  public static final int STACK_TRACES_FIELD_NUMBER = 1;
  private com.google.protobuf.LazyStringList stackTraces_;
  /**
   *
   *
   *

   * Stack traces leading to the point where the XSS occurred.
   *

   *
   * repeated string stack_traces = 1;
   *
   * @return A list containing the stackTraces.
   */
  public com.google.protobuf.ProtocolStringList getStackTracesList() {
    return stackTraces_;
  }
  /**
   *
   *
   *

   * Stack traces leading to the point where the XSS occurred.
   *

   *
   * repeated string stack_traces = 1;
   *
   * @return The count of stackTraces.
   */
  public int getStackTracesCount() {
    return stackTraces_.size();
  }
  /**
   *
   *
   *

   * Stack traces leading to the point where the XSS occurred.
   *

   *
   * repeated string stack_traces = 1;
   *
   * @param index The index of the element to return.
   * @return The stackTraces at the given index.
   */
  public java.lang.String getStackTraces(int index) {
    return stackTraces_.get(index);
  }
  /**
   *
   *
   *

   * Stack traces leading to the point where the XSS occurred.
   *

   *
   * repeated string stack_traces = 1;
   *
   * @param index The index of the value to return.
   * @return The bytes of the stackTraces at the given index.
   */
  public com.google.protobuf.ByteString getStackTracesBytes(int index) {
    return stackTraces_.getByteString(index);
  }

  public static final int ERROR_MESSAGE_FIELD_NUMBER = 2;
  private volatile java.lang.Object errorMessage_;
  /**
   *
   *
   *

   * An error message generated by a javascript breakage.
   *

   *
   * string error_message = 2;
   *
   * @return The errorMessage.
   */
  @java.lang.Override
  public java.lang.String getErrorMessage() {
    java.lang.Object ref = errorMessage_;
    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();
      errorMessage_ = s;
      return s;
    }
  }
  /**
   *
   *
   *

   * An error message generated by a javascript breakage.
   *

   *
   * string error_message = 2;
   *
   * @return The bytes for errorMessage.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getErrorMessageBytes() {
    java.lang.Object ref = errorMessage_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      errorMessage_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  private byte memoizedIsInitialized = -1;

  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    for (int i = 0; i < stackTraces_.size(); i++) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, stackTraces_.getRaw(i));
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(errorMessage_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 2, errorMessage_);
    }
    getUnknownFields().writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    {
      int dataSize = 0;
      for (int i = 0; i < stackTraces_.size(); i++) {
        dataSize += computeStringSizeNoTag(stackTraces_.getRaw(i));
      }
      size += dataSize;
      size += 1 * getStackTracesList().size();
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(errorMessage_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, errorMessage_);
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof com.google.cloud.websecurityscanner.v1alpha.Xss)) {
      return super.equals(obj);
    }
    com.google.cloud.websecurityscanner.v1alpha.Xss other =
        (com.google.cloud.websecurityscanner.v1alpha.Xss) obj;

    if (!getStackTracesList().equals(other.getStackTracesList())) return false;
    if (!getErrorMessage().equals(other.getErrorMessage())) return false;
    if (!getUnknownFields().equals(other.getUnknownFields())) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (getStackTracesCount() > 0) {
      hash = (37 * hash) + STACK_TRACES_FIELD_NUMBER;
      hash = (53 * hash) + getStackTracesList().hashCode();
    }
    hash = (37 * hash) + ERROR_MESSAGE_FIELD_NUMBER;
    hash = (53 * hash) + getErrorMessage().hashCode();
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseDelimitedFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(com.google.cloud.websecurityscanner.v1alpha.Xss prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   *
   *
   *

   * Information reported for an XSS.
   *

   *
   * Protobuf type {@code google.cloud.websecurityscanner.v1alpha.Xss}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.websecurityscanner.v1alpha.Xss)
      com.google.cloud.websecurityscanner.v1alpha.XssOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.websecurityscanner.v1alpha.FindingAddonProto
          .internal_static_google_cloud_websecurityscanner_v1alpha_Xss_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.websecurityscanner.v1alpha.FindingAddonProto
          .internal_static_google_cloud_websecurityscanner_v1alpha_Xss_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.websecurityscanner.v1alpha.Xss.class,
              com.google.cloud.websecurityscanner.v1alpha.Xss.Builder.class);
    }

    // Construct using com.google.cloud.websecurityscanner.v1alpha.Xss.newBuilder()
    private Builder() {}

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      stackTraces_ = com.google.protobuf.LazyStringArrayList.EMPTY;
      bitField0_ = (bitField0_ & ~0x00000001);
      errorMessage_ = "";

      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.websecurityscanner.v1alpha.FindingAddonProto
          .internal_static_google_cloud_websecurityscanner_v1alpha_Xss_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.websecurityscanner.v1alpha.Xss getDefaultInstanceForType() {
      return com.google.cloud.websecurityscanner.v1alpha.Xss.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.cloud.websecurityscanner.v1alpha.Xss build() {
      com.google.cloud.websecurityscanner.v1alpha.Xss result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.cloud.websecurityscanner.v1alpha.Xss buildPartial() {
      com.google.cloud.websecurityscanner.v1alpha.Xss result =
          new com.google.cloud.websecurityscanner.v1alpha.Xss(this);
      int from_bitField0_ = bitField0_;
      if (((bitField0_ & 0x00000001) != 0)) {
        stackTraces_ = stackTraces_.getUnmodifiableView();
        bitField0_ = (bitField0_ & ~0x00000001);
      }
      result.stackTraces_ = stackTraces_;
      result.errorMessage_ = errorMessage_;
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.websecurityscanner.v1alpha.Xss) {
        return mergeFrom((com.google.cloud.websecurityscanner.v1alpha.Xss) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.websecurityscanner.v1alpha.Xss other) {
      if (other == com.google.cloud.websecurityscanner.v1alpha.Xss.getDefaultInstance())
        return this;
      if (!other.stackTraces_.isEmpty()) {
        if (stackTraces_.isEmpty()) {
          stackTraces_ = other.stackTraces_;
          bitField0_ = (bitField0_ & ~0x00000001);
        } else {
          ensureStackTracesIsMutable();
          stackTraces_.addAll(other.stackTraces_);
        }
        onChanged();
      }
      if (!other.getErrorMessage().isEmpty()) {
        errorMessage_ = other.errorMessage_;
        onChanged();
      }
      this.mergeUnknownFields(other.getUnknownFields());
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 10:
              {
                java.lang.String s = input.readStringRequireUtf8();
                ensureStackTracesIsMutable();
                stackTraces_.add(s);
                break;
              } // case 10
            case 18:
              {
                errorMessage_ = input.readStringRequireUtf8();

                break;
              } // case 18
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private com.google.protobuf.LazyStringList stackTraces_ =
        com.google.protobuf.LazyStringArrayList.EMPTY;

    private void ensureStackTracesIsMutable() {
      if (!((bitField0_ & 0x00000001) != 0)) {
        stackTraces_ = new com.google.protobuf.LazyStringArrayList(stackTraces_);
        bitField0_ |= 0x00000001;
      }
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @return A list containing the stackTraces.
     */
    public com.google.protobuf.ProtocolStringList getStackTracesList() {
      return stackTraces_.getUnmodifiableView();
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @return The count of stackTraces.
     */
    public int getStackTracesCount() {
      return stackTraces_.size();
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @param index The index of the element to return.
     * @return The stackTraces at the given index.
     */
    public java.lang.String getStackTraces(int index) {
      return stackTraces_.get(index);
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @param index The index of the value to return.
     * @return The bytes of the stackTraces at the given index.
     */
    public com.google.protobuf.ByteString getStackTracesBytes(int index) {
      return stackTraces_.getByteString(index);
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @param index The index to set the value at.
     * @param value The stackTraces to set.
     * @return This builder for chaining.
     */
    public Builder setStackTraces(int index, java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      ensureStackTracesIsMutable();
      stackTraces_.set(index, value);
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @param value The stackTraces to add.
     * @return This builder for chaining.
     */
    public Builder addStackTraces(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      ensureStackTracesIsMutable();
      stackTraces_.add(value);
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @param values The stackTraces to add.
     * @return This builder for chaining.
     */
    public Builder addAllStackTraces(java.lang.Iterable<java.lang.String> values) {
      ensureStackTracesIsMutable();
      com.google.protobuf.AbstractMessageLite.Builder.addAll(values, stackTraces_);
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @return This builder for chaining.
     */
    public Builder clearStackTraces() {
      stackTraces_ = com.google.protobuf.LazyStringArrayList.EMPTY;
      bitField0_ = (bitField0_ & ~0x00000001);
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Stack traces leading to the point where the XSS occurred.
     *

     *
     * repeated string stack_traces = 1;
     *
     * @param value The bytes of the stackTraces to add.
     * @return This builder for chaining.
     */
    public Builder addStackTracesBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      ensureStackTracesIsMutable();
      stackTraces_.add(value);
      onChanged();
      return this;
    }

    private java.lang.Object errorMessage_ = "";
    /**
     *
     *
     *

     * An error message generated by a javascript breakage.
     *

     *
     * string error_message = 2;
     *
     * @return The errorMessage.
     */
    public java.lang.String getErrorMessage() {
      java.lang.Object ref = errorMessage_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        errorMessage_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     *

     * An error message generated by a javascript breakage.
     *

     *
     * string error_message = 2;
     *
     * @return The bytes for errorMessage.
     */
    public com.google.protobuf.ByteString getErrorMessageBytes() {
      java.lang.Object ref = errorMessage_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        errorMessage_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     *

     * An error message generated by a javascript breakage.
     *

     *
     * string error_message = 2;
     *
     * @param value The errorMessage to set.
     * @return This builder for chaining.
     */
    public Builder setErrorMessage(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }

      errorMessage_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * An error message generated by a javascript breakage.
     *

     *
     * string error_message = 2;
     *
     * @return This builder for chaining.
     */
    public Builder clearErrorMessage() {

      errorMessage_ = getDefaultInstance().getErrorMessage();
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * An error message generated by a javascript breakage.
     *

     *
     * string error_message = 2;
     *
     * @param value The bytes for errorMessage to set.
     * @return This builder for chaining.
     */
    public Builder setErrorMessageBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);

      errorMessage_ = value;
      onChanged();
      return this;
    }

    @java.lang.Override
    public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }

    // @@protoc_insertion_point(builder_scope:google.cloud.websecurityscanner.v1alpha.Xss)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.websecurityscanner.v1alpha.Xss)
  private static final com.google.cloud.websecurityscanner.v1alpha.Xss DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.websecurityscanner.v1alpha.Xss();
  }

  public static com.google.cloud.websecurityscanner.v1alpha.Xss getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<Xss> PARSER =
      new com.google.protobuf.AbstractParser<Xss>() {
        @java.lang.Override
        public Xss parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

  public static com.google.protobuf.Parser<Xss> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<Xss> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.cloud.websecurityscanner.v1alpha.Xss getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}


text:
package com.oracle.acs.client;

public interface GenericConnection {

	void prepareConection() throws Throwable;

	void createConection() throws Throwable;

	void executeTest() throws Throwable;

	void resetIssues() throws Throwable;

	void executeTestMonitor() throws Throwable;

	void verifyConnection() throws Throwable;;

	void closeConnection() throws Throwable;

	void purgeConection() throws Throwable;

}

redpajama_set_name: RedPajamaGithub


text:
layout: home
title: Points Unknown - Resources
permalink: /resources/
---
Here you will find a list of GIS and mapping resources, including data, tutorials, books, and blogs. Although this is by no means a complete or comprehensive list we hope it will provide guidance, ideas, inspiration, and help you in your mapping work.

# Data Sources
**Data resources at Columbia University:**

* [Digital Social Science Center (DSSC)](http://library.columbia.edu/locations/dssc.html): in Lehman Library is the chief GIS Data Library for the overall University. They purchase and maintain their own collection of data, including historical datasets for New York City, and have Data Librarians who are able to help students in both finding and working with geospatial data. The DSSC is located in Lehman Library in the School of International and Public Affairs (SIPA) at 118th Street and Amsterdam, and is open to all Columbia Students with a valid ID. Please refer to their website for hours.

* [GeoData@Columbia](https://geodata.library.columbia.edu/): hosted by the DSSC, this portal provides access to geographic data from the leading universities of the world.

* [SEDAC / CIESIN](http://sedac.ciesin.columbia.edu/): The Center for International Earth Science Information Network (CIESIN) is a center within the Earth Institute at Columbia University. CIESIN works at the intersection of the social, natural, and information sciences, and specializes in on-line data and information management, spatial data integration and training, and interdisciplinary research related to human interactions in the environment. Along with NASA they produce the [Gridded Population of the World](http://sedac.ciesin.columbia.edu/data/collection/gpw-v4) dataset, which models the distribution of human population (counts and densities) on a continuous global surface. This is probably the most complete and accurate global population dataset in the world.

**New York City data:**
* [NYC Open Data Portal](https://opendata.cityofnewyork.us/):

    * [Building footprints](https://data.cityofnewyork.us/Housing-Development/Building-Footprints/nqwf-w8eh)

    * [NYC Planimetrics](https://data.cityofnewyork.us/Transportation/NYC-Planimetrics/wt4d-p43d/data): A comprehensive database including boardwalks, building footprints, cooling towers, curbs, elevation data, hydro structures, hydrography, medians, open spaces, parks, parking lots, pavement edges, plazas, railroads, railroad structures, retaining walls, roadbeds, shorelines, sidewalks, sidewalk centerlines, swimming pools, transport structures, under construction.

    * [311 complaints](https://data.cityofnewyork.us/Social-Services/311-Service-Requests-from-2010-to-Present/erm2-nwe9/data)

    * [Hurricane evacuation zones](https://data.cityofnewyork.us/Public-Safety/Hurricane-Evacuation-Zones/uihr-hn7s/data)

    * [Hydrography](https://data.cityofnewyork.us/Environment/Hydrography/drh3-e2fd)

* [BYTES of the BIG APPLE](http://www1.nyc.gov/site/planning/data-maps/open-data.page): datasets by the NYC Department of City Planning including the following:

    * PLUTO: building lots, including data for zoning, special purpose districts, land use, built and lot areas, year built, etc.

    * NYC GIS Zoning Features: zoning districts, special purpose districts, special purpose district subdistricts, limited height districts, commercial overlay zones, and zoning map amendments.

    * LION: A single line street base map representing the city's streets and other linear geographic features such as shorelines, surface rail lines and boardwalks, along with feature names and address ranges for each addressable street segment.

    * Administrative and Political Districts: including boroughs, community districts, political and election districts and school, fire, health and police areas.

    * Neighborhood tabulation areas

    * FRESH Food Stores Zoning Boundaries

    * Inclusionary Housing

    * Sidewalk Cafes

    * NYC Public Accessible Waterfront

    * NYCDP Manhattan Bike Counts

    * Hurricane evacuation zones

    * Other

* [NYC 3D Building Model](http://www1.nyc.gov/site/doitt/initiatives/3d-building.page)

* [Citibike](https://www.citibikenyc.com/system-data) data, including stations and trips.

* [Taxi and Limousine Commission](http://www.nyc.gov/html/tlc/html/about/trip_record_data.shtml): yellow and green taxi trip and some "for-hire" vehicle data (Uber, Lyft, etc). Note, this "for-hire" data is very limited and should not be considered representative.

* MTA:

    * [Subway turnstile data](http://web.mta.info/developers/turnstile.html)

    * [Subway stations](https://data.cityofnewyork.us/Transportation/Subway-Stations/arq3-7z49/data)

**New York State Data:**
* [New York State GIS Clearinghouse](https://gis.ny.gov/)

**Topography Data:**

* [Cornell University Geospatial Information Repository (CUGIR)](http://cugir.mannlib.cornell.edu/)

* [US Geological Survey (USGS)](https://viewer.nationalmap.gov/launch/)

**U.S. Data:**

* [Data.gov](https://www.data.gov/)

* [US Census Bureau - American FactFinder](https://factfinder.census.gov/faces/nav/jsf/pages/index.xhtml)

* [US Census Bureau - TIGER Geography](https://www.census.gov/geo/maps-data/data/tiger.html): Census geometry files

* [IPUMS National Historic GIS](https://www.nhgis.org/): Historic census data

* [Social Explorer](https://www.socialexplorer.com/): US demographic data (free on Columbia University network)

**International Data:**

* Open Street Map (worldwide data):

  * [Mapzen Metro Extracts](https://mapzen.com/data/metro-extracts/): City level data

  * [Geofabrik Data Extracts](http://download.geofabrik.de/)

* [Natural Earth](http://www.naturalearthdata.com/)

* [Diva GIS](http://www.diva-gis.org/)

# Tutorials
* [Center for Spatial Research](http://c4sr.columbia.edu/tutorials)

Books
=====

* _Design for Information_, Isabel Meirelles

* _Semiology of Graphics_, Jacques Bertin

* _The Visual Display of Quantitative Information_, Edward Tufte

* _Envisioning Information_, Edward Tufte

* _The Map Reader_, Martin Dodge (editor)

* _Drawing the Line: Tales of Maps and Cartocontroversies_, Mark Monmonier

* _Ground Truth: The Social Implications of Geographic Information Systems_, John Pickles

* _Data Flow: Visualizing Information in Graphic Design_, Robert Klanten (editor)

* _Data Flow 2: Visualizing Information in Graphic Design_, Robert Klanten (editor)

* _Atlas of Shrinking Cities_, Byer Elke

* _Petrochemical America_, Richard Misrach and Kate Orff

* _Data Points_, Nathan Yau

* _Visualizing Information for Advocacy_, Tactical Technology Creative

# Blogs & Websites
**Critical GIS:**
* [List of critical GIS articles](https://criticalgis.blogspot.com/p/critical-gis-bibliography.html)

**Maps and data visualization in journalism:**
* [The Economist - Graphic Detail](https://www.economist.com/blogs/graphicdetail)

* [The New York Times - The Upshot](https://www.nytimes.com/section/upshot)

* [FiveThirtyEight - Best - And Weirdest - Charts 2016](https://fivethirtyeight.com/features/the-52-best-and-weirdest-charts-we-made-in-2016/)

* [Huffpost - Data](http://data.huffingtonpost.com/)

* [La Times - Dear 2016](http://www.latimes.com/projects/la-g-2016-in-graphics/)

* [Wall Street Journal - Graphics](https://graphics.wsj.com/)

* [The Washington Post - 16 in '16](https://www.washingtonpost.com/graphics/national/2016-in-graphics/)

* [Atlas - Charts by Quartz](https://www.theatlas.com/)

* [The New York Times - 2016: The Year in Visual Stories and Graphics](https://www.nytimes.com/interactive/2016/12/28/us/year-in-interactive-graphics.html?mcubz=0)

* [Lapham's Quarterly - Maps](https://www.laphamsquarterly.org/archive/maps)

* [Lapham's Quarterly - Charts & Graphs](https://www.laphamsquarterly.org/archive/charts-graphs)

**Journalism Resources:**
* [Duff Wilson: Who is John Doe?](http://www.reporter.org/desktop/tips/johndoe.htm)

* [Reporter's Desktop](http://www.reporter.org/desktop/)

* [Lexis Nexis Academic](https://advance.lexis.com/bisacademicresearchhome?crid=00ee9020-f03a-47ac-9037-78b3424dec31&pdmfid=1516831&pdisurlapi=true)

* [ProQuest Historical Newspapers](https://clio.columbia.edu/catalog/3262558)

* [Google Scholar](https://scholar.google.com/)

* [Google's Guide to Advanced Search Operators](http://www.googleguide.com/advanced_operators_reference.html)

* [Investigative Research Links - Margot Williams](https://drive.google.com/file/d/0BxpHYfw0ye3NWVdMMTRVQnJhNGc/view?pli=1)

* [Online Research Tools and Investigative Techniques from Paul Myers](http://gijn.org/2015/05/05/online-research-tools-and-investigation-techniques/)

* [Online research to investigate the who, where, and when of a person from Hank van Ess](http://verificationhandbook.com/book2/chapter2.php)

* [Social Media Sleuthing](https://drive.google.com/file/d/0B_-zyGELtwBLWkFfNEpoS3MzMG8/view?usp=sharing)

* [Social Media Tools from Doug Haddix](https://docs.google.com/spreadsheets/d/1XXATgpZmhFk2HcVaSuSCTnhhXoAIi7pmNflRGLY3h-M/edit?pli=1#gid=0)

* [How to Research an Individual's Background](https://drive.google.com/file/d/0B7UAuEqoequKdFAzVkdBQzhjRTQ/view?pref=2&pli=1)

* [JSTOR](http://www.jstor.org.ezproxy.cul.columbia.edu/)

* [Web of Science](http://apps.webofknowledge.com.ezproxy.cul.columbia.edu/WOS_GeneralSearch_input.do?product=WOS&search_mode=GeneralSearch&SID=3CfDcWvSrO2TKKAzVpL&preferencesSaved=)

**Data visualization blogs:**
* [Visualising Data](http://www.visualisingdata.com/)

* [Flowingdata](https://flowingdata.com/)

* [Information Aesthetics](http://infosthetics.com/)

* [Visualoop](http://visualoop.com/)

* [Visual Complexity](http://www.visualcomplexity.com/vc/)

**Collections of Maps:**
* [Library of Congress](https://www.loc.gov/maps/collections/)

* [USGS - The National Geologic Map Database](https://ngmdb.usgs.gov/ngmdb/ngmdb_home.html)

* [Territory](http://themapisnot.com/)

* [Sensory Maps](http://sensorymaps.com/)

**Data visualization agencies:**
* [Periscopic](http://www.periscopic.com/)

* [Accurat](https://www.accurat.it/)

* [Truth & Beauty](http://truth-and-beauty.net/)

* [Nicholas Felton](http://feltron.com/)

* [Fathom](https://fathom.info/)

**Online Color Tools:**
* [ColorBrewer](http://colorbrewer2.org/#type=sequential&scheme=BuGn&n=3)

* [Adobe Color CC](https://color.adobe.com/create/color-wheel/)

* [ColorHexa](http://www.colorhexa.com/)

* [i want hue](http://tools.medialab.sciences-po.fr/iwanthue/)

* [Colorpicker for data](http://tristen.ca/hcl-picker/#/hlc/6/1/15534C/E2E062)

* [Colorgorical](http://vrl.cs.brown.edu/color)

* [How To Avoid Equidistant HSV Colors](https://www.vis4.net/blog/posts/avoid-equidistant-hsv-colors/)

* [Your Friendly Guide to Colors in Data Visualization](https://lisacharlotterost.github.io/2016/04/22/Colors-for-DataVis/)

* [How We Created Color Scales](https://datavisualization.ch/inside/how-we-created-color-scales/)


text:
using syncer::SyncService;
using vivaldi::VivaldiSyncServiceFactory;
using vivaldi::VivaldiSyncServiceImpl;

namespace extensions {

namespace {
bool WriteFileWrapper(const base::FilePath& filename,
                      std::unique_ptr<std::string> data) {
  return base::WriteFile(filename, *data);
}

vivaldi::sync::CycleStatus ToVivaldiCycleStatus(
    ::vivaldi::VivaldiSyncUIHelper::CycleStatus cycle_status) {
  switch (cycle_status) {
    case ::vivaldi::VivaldiSyncUIHelper::NOT_SYNCED:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_NOT_SYNCED;
    case ::vivaldi::VivaldiSyncUIHelper::SUCCESS:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_SUCCESS;
    case ::vivaldi::VivaldiSyncUIHelper::IN_PROGRESS:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_IN_PROGRESS;
    case ::vivaldi::VivaldiSyncUIHelper::AUTH_ERROR:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_AUTH_ERROR;
    case ::vivaldi::VivaldiSyncUIHelper::SERVER_ERROR:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_SERVER_ERROR;
    case ::vivaldi::VivaldiSyncUIHelper::NETWORK_ERROR:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_NETWORK_ERROR;
    case ::vivaldi::VivaldiSyncUIHelper::CLIENT_ERROR:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_CLIENT_ERROR;
    case ::vivaldi::VivaldiSyncUIHelper::CONFLICT:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_CONFLICT;
    case ::vivaldi::VivaldiSyncUIHelper::THROTTLED:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_THROTTLED;
    case ::vivaldi::VivaldiSyncUIHelper::OTHER_ERROR:
      return vivaldi::sync::CycleStatus::CYCLE_STATUS_OTHER_ERROR;
  }
}

std::vector<extensions::vivaldi::sync::DisableReason>
ToVivaldiSyncDisableReasons(syncer::SyncService::DisableReasonSet reasons) {
  std::vector<extensions::vivaldi::sync::DisableReason> disable_reasons;

  for (auto reason : reasons) {
    switch (reason) {
      case syncer::SyncService::DISABLE_REASON_PLATFORM_OVERRIDE:
        disable_reasons.push_back(
            vivaldi::sync::DisableReason::DISABLE_REASON_PLATFORM_OVERRIDE);
        break;
      case syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY:
        disable_reasons.push_back(
            vivaldi::sync::DisableReason::DISABLE_REASON_ENTERPRISE_POLICY);
        break;
      case syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN:
        disable_reasons.push_back(
            vivaldi::sync::DisableReason::DISABLE_REASON_NOT_SIGNED_IN);
        break;
      case syncer::SyncService::DISABLE_REASON_USER_CHOICE:
        disable_reasons.push_back(
            vivaldi::sync::DisableReason::DISABLE_REASON_USER_CHOICE);
        break;
      case syncer::SyncService::DISABLE_REASON_UNRECOVERABLE_ERROR:
        disable_reasons.push_back(
            vivaldi::sync::DisableReason::DISABLE_REASON_UNRECOVERABLE_ERROR);
        break;
      default:
        break;
    }
  }
  return disable_reasons;
}

vivaldi::sync::ProtocolErrorType ToVivaldiSyncProtocolErrorType(
    syncer::SyncProtocolErrorType error_type) {
  switch (error_type) {
    case syncer::SYNC_SUCCESS:
      return vivaldi::sync::ProtocolErrorType::PROTOCOL_ERROR_TYPE_SUCCESS;
    case syncer::NOT_MY_BIRTHDAY:
      return vivaldi::sync::ProtocolErrorType::
          PROTOCOL_ERROR_TYPE_NOT_MY_BIRTHDAY;
    case syncer::THROTTLED:
      return vivaldi::sync::ProtocolErrorType::PROTOCOL_ERROR_TYPE_THROTTLED;
    case syncer::CLEAR_PENDING:
      return vivaldi::sync::ProtocolErrorType::
          PROTOCOL_ERROR_TYPE_CLEAR_PENDING;
    case syncer::TRANSIENT_ERROR:
      return vivaldi::sync::ProtocolErrorType::
          PROTOCOL_ERROR_TYPE_TRANSIENT_ERROR;
    case syncer::MIGRATION_DONE:
      return vivaldi::sync::ProtocolErrorType::
          PROTOCOL_ERROR_TYPE_MIGRATION_DONE;
    case syncer::DISABLED_BY_ADMIN:
      return vivaldi::sync::ProtocolErrorType::
          PROTOCOL_ERROR_TYPE_DISABLED_BY_ADMIN;
    case syncer::PARTIAL_FAILURE:
      return vivaldi::sync::ProtocolErrorType::
          PROTOCOL_ERROR_TYPE_PARTIAL_FAILURE;
    case syncer::CLIENT_DATA_OBSOLETE:
      return vivaldi::sync::ProtocolErrorType::
          PROTOCOL_ERROR_TYPE_CLIENT_DATA_OBSOLETE;
    case syncer::ENCRYPTION_OBSOLETE:
      return vivaldi::sync::ProtocolErrorType::
          PROTOCOL_ERROR_TYPE_ENCRYPTION_OBSOLETE;
    case syncer::UNKNOWN_ERROR:
      return vivaldi::sync::ProtocolErrorType::PROTOCOL_ERROR_TYPE_UNKNOWN;
  }
}

vivaldi::sync::ClientAction ToVivaldiSyncClientAction(
    syncer::ClientAction client_action) {
  switch (client_action) {
    case syncer::UPGRADE_CLIENT:
      return vivaldi::sync::ClientAction::CLIENT_ACTION_UPGRADE_CLIENT;
    case syncer::DISABLE_SYNC_ON_CLIENT:
      return vivaldi::sync::ClientAction::CLIENT_ACTION_DISABLE_SYNC_ON_CLIENT;
    case syncer::STOP_SYNC_FOR_DISABLED_ACCOUNT:
      return vivaldi::sync::ClientAction::
          CLIENT_ACTION_STOP_SYNC_FOR_DISABLED_ACCOUNT;
    case syncer::RESET_LOCAL_SYNC_DATA:
      return vivaldi::sync::ClientAction::CLIENT_ACTION_RESET_LOCAL_SYNC_DATA;
    case syncer::UNKNOWN_ACTION:
      return vivaldi::sync::ClientAction::CLIENT_ACTION_UNKNOWN;
  }
}

vivaldi::sync::DataType ToVivaldiSyncDataType(
    syncer::UserSelectableType data_type) {
  switch (data_type) {
    case syncer::UserSelectableType::kBookmarks:
      return vivaldi::sync::DataType::DATA_TYPE_BOOKMARKS;
    case syncer::UserSelectableType::kPreferences:
      return vivaldi::sync::DataType::DATA_TYPE_PREFERENCES;
    case syncer::UserSelectableType::kPasswords:
      return vivaldi::sync::DataType::DATA_TYPE_PASSWORDS;
    case syncer::UserSelectableType::kAutofill:
      return vivaldi::sync::DataType::DATA_TYPE_AUTOFILL;
    case syncer::UserSelectableType::kHistory:
      return vivaldi::sync::DataType::DATA_TYPE_TYPED_URLS;
    case syncer::UserSelectableType::kExtensions:
      return vivaldi::sync::DataType::DATA_TYPE_EXTENSIONS;
    case syncer::UserSelectableType::kNotes:
      return vivaldi::sync::DataType::DATA_TYPE_NOTES;
    case syncer::UserSelectableType::kReadingList:
      return vivaldi::sync::DataType::DATA_TYPE_READING_LIST;
    default:
      NOTREACHED();
      return vivaldi::sync::DataType::DATA_TYPE_NONE;
  }
}

absl::optional<syncer::UserSelectableType> FromVivaldiSyncDataType(
    vivaldi::sync::DataType data_type) {
  switch (data_type) {
    case vivaldi::sync::DataType::DATA_TYPE_BOOKMARKS:
      return syncer::UserSelectableType::kBookmarks;
    case vivaldi::sync::DataType::DATA_TYPE_PASSWORDS:
      return syncer::UserSelectableType::kPasswords;
    case vivaldi::sync::DataType::DATA_TYPE_PREFERENCES:
      return syncer::UserSelectableType::kPreferences;
    case vivaldi::sync::DataType::DATA_TYPE_AUTOFILL:
      return syncer::UserSelectableType::kAutofill;
    case vivaldi::sync::DataType::DATA_TYPE_TYPED_URLS:
      return syncer::UserSelectableType::kHistory;
    case vivaldi::sync::DataType::DATA_TYPE_EXTENSIONS:
      return syncer::UserSelectableType::kExtensions;
    case vivaldi::sync::DataType::DATA_TYPE_NOTES:
      return syncer::UserSelectableType::kNotes;
    case vivaldi::sync::DataType::DATA_TYPE_READING_LIST:
      return syncer::UserSelectableType::kReadingList;
    default:
      NOTREACHED();
      return absl::nullopt;
  }
}

vivaldi::sync::CycleData GetLastCycleData(Profile* profile) {
  VivaldiSyncServiceImpl* sync_service =
      VivaldiSyncServiceFactory::GetForProfileVivaldi(profile);
  vivaldi::sync::CycleData cycle_data;
  cycle_data.is_ready = true;

  if (!sync_service) {
    cycle_data.cycle_start_time = 0;
    cycle_data.download_updates_status =
        vivaldi::sync::CycleStatus::CYCLE_STATUS_NOT_SYNCED;
    cycle_data.commit_status =
        vivaldi::sync::CycleStatus::CYCLE_STATUS_NOT_SYNCED;
    return cycle_data;
  }

  ::vivaldi::VivaldiSyncUIHelper::CycleData helper_cycle_data =
      sync_service->ui_helper()->GetCycleData();

  cycle_data.cycle_start_time = helper_cycle_data.cycle_start_time.ToJsTime();
  cycle_data.download_updates_status =
      ToVivaldiCycleStatus(helper_cycle_data.download_updates_status);
  cycle_data.commit_status =
      ToVivaldiCycleStatus(helper_cycle_data.commit_status);
  cycle_data.next_retry_time = helper_cycle_data.next_retry_time.ToJsTime();

  return cycle_data;
}

vivaldi::sync::EngineData GetEngineData(Profile* profile) {
  VivaldiSyncServiceImpl* sync_service =
      VivaldiSyncServiceFactory::GetForProfileVivaldi(profile);

  vivaldi::sync::EngineData engine_data;
  engine_data.is_ready = true;

  if (!sync_service) {
    engine_data.engine_state = vivaldi::sync::EngineState::ENGINE_STATE_FAILED;
    if (!switches::IsSyncAllowedByFlag())
      engine_data.disable_reasons = {
          vivaldi::sync::DisableReason::DISABLE_REASON_FLAG};
    engine_data.protocol_error_type =
        vivaldi::sync::ProtocolErrorType::PROTOCOL_ERROR_TYPE_UNKNOWN;
    engine_data.protocol_error_client_action =
        vivaldi::sync::ClientAction::CLIENT_ACTION_UNKNOWN;

    return engine_data;
  }

  if (sync_service->is_clearing_sync_data()) {
    engine_data.engine_state =
        vivaldi::sync::EngineState::ENGINE_STATE_CLEARING_DATA;
  } else if (!sync_service->GetUserSettings()->IsSyncRequested() ||
             sync_service->GetTransportState() ==
                 syncer::SyncService::TransportState::START_DEFERRED) {
    engine_data.engine_state = vivaldi::sync::EngineState::ENGINE_STATE_STOPPED;

  } else if (!sync_service->CanSyncFeatureStart()) {
    engine_data.engine_state = vivaldi::sync::EngineState::ENGINE_STATE_FAILED;

  } else if (sync_service->IsEngineInitialized()) {
    if (sync_service->GetTransportState() ==
            syncer::SyncService::TransportState::
                PENDING_DESIRED_CONFIGURATION ||
        !sync_service->GetUserSettings()->IsFirstSetupComplete()) {
      engine_data.engine_state =
          vivaldi::sync::EngineState::ENGINE_STATE_CONFIGURATION_PENDING;
    } else {
      engine_data.engine_state =
          vivaldi::sync::EngineState::ENGINE_STATE_STARTED;
    }

  } else if (sync_service->GetSyncTokenStatusForDebugging().connection_status ==
             syncer::CONNECTION_SERVER_ERROR) {
    engine_data.engine_state =
        vivaldi::sync::EngineState::ENGINE_STATE_STARTING_SERVER_ERROR;
  } else {
    engine_data.engine_state =
        vivaldi::sync::EngineState::ENGINE_STATE_STARTING;
  }

  engine_data.disable_reasons =
      ToVivaldiSyncDisableReasons(sync_service->GetDisableReasons());

  syncer::SyncStatus status;
  sync_service->QueryDetailedSyncStatusForDebugging(&status);

  engine_data.protocol_error_type =
      ToVivaldiSyncProtocolErrorType(status.sync_protocol_error.error_type);
  engine_data.protocol_error_description =
      status.sync_protocol_error.error_description;
  engine_data.protocol_error_client_action =
      ToVivaldiSyncClientAction(status.sync_protocol_error.action);

  engine_data.is_encrypting_everything =
      sync_service->IsEngineInitialized()
          ? sync_service->GetUserSettings()->IsEncryptEverythingEnabled()
          : false;
  engine_data.uses_encryption_password =
      sync_service->GetUserSettings()->IsUsingExplicitPassphrase();
  engine_data.needs_decryption_password =
      sync_service->GetUserSettings()
          ->IsPassphraseRequiredForPreferredDataTypes();
  engine_data.is_setup_in_progress = sync_service->IsSetupInProgress();
  engine_data.is_first_setup_complete =
      sync_service->GetUserSettings()->IsFirstSetupComplete();

  engine_data.sync_everything =
      sync_service->GetUserSettings()->IsSyncEverythingEnabled();
  syncer::UserSelectableTypeSet chosen_types =
      sync_service->GetUserSettings()->GetSelectedTypes();
  std::vector<vivaldi::sync::DataType> data_types;
  for (const syncer::UserSelectableType data_type :
       syncer::UserSelectableTypeSet::All()) {
    // Skip the model types that don't make sense for us to synchronize.
    if (data_type == syncer::UserSelectableType::kThemes ||
        data_type == syncer::UserSelectableType::kApps ||
        // Syncing typedUrls already syncs sessions anyway. For now we group
        // both in our UI
        data_type == syncer::UserSelectableType::kTabs ||
        // Wifi configuration is only used in ChromeOS.
        data_type == syncer::UserSelectableType::kWifiConfigurations) {
      continue;
    }

    vivaldi::sync::DataTypeSelection data_type_selection;
    data_type_selection.data_type = ToVivaldiSyncDataType(data_type);
    data_type_selection.enabled = chosen_types.Has(data_type);
    engine_data.data_types.push_back(std::move(data_type_selection));
  }

  return engine_data;
}

}  // anonymous namespace

SyncEventRouter::SyncEventRouter(Profile* profile) : profile_(profile) {
  SyncService* sync_service = VivaldiSyncServiceFactory::GetForProfile(profile);
  if (sync_service)
    sync_service->AddObserver(this);
}

SyncEventRouter::~SyncEventRouter() {}

void SyncEventRouter::OnStateChanged(syncer::SyncService* sync) {
  ::vivaldi::BroadcastEvent(
      vivaldi::sync::OnEngineStateChanged::kEventName,
      vivaldi::sync::OnEngineStateChanged::Create(GetEngineData(profile_)),
      profile_);
}

void SyncEventRouter::OnSyncCycleCompleted(syncer::SyncService* sync) {
  ::vivaldi::BroadcastEvent(
      vivaldi::sync::OnCycleCompleted::kEventName,
      vivaldi::sync::OnCycleCompleted::Create(GetLastCycleData(profile_)),
      profile_);
}

void SyncEventRouter::OnSyncShutdown(syncer::SyncService* sync) {
  sync->RemoveObserver(this);
}

SyncAPI::SyncAPI(content::BrowserContext* context) : browser_context_(context) {
  EventRouter* event_router = EventRouter::Get(browser_context_);
  event_router->RegisterObserver(
      this, vivaldi::sync::OnEngineStateChanged::kEventName);
  event_router->RegisterObserver(this,
                                 vivaldi::sync::OnCycleCompleted::kEventName);
}

static base::LazyInstance<
    BrowserContextKeyedAPIFactory<SyncAPI>>::DestructorAtExit g_factory_sync =
    LAZY_INSTANCE_INITIALIZER;

// static
BrowserContextKeyedAPIFactory<SyncAPI>* SyncAPI::GetFactoryInstance() {
  return g_factory_sync.Pointer();
}

SyncAPI::~SyncAPI() {}

void SyncAPI::OnListenerAdded(const EventListenerInfo& details) {
  sync_event_router_.reset(
      new SyncEventRouter(Profile::FromBrowserContext(browser_context_)));
  EventRouter::Get(browser_context_)->UnregisterObserver(this);
}

void SyncAPI::StartSyncSetup(syncer::SyncService* sync) {
  if (!sync_setup_handle_.get())
    sync_setup_handle_ = sync->GetSetupInProgressHandle();
}

// KeyedService implementation.
void SyncAPI::Shutdown() {
  EventRouter::Get(browser_context_)->UnregisterObserver(this);
}

void SyncAPI::SyncSetupComplete() {
  sync_setup_handle_.reset();
}

ExtensionFunction::ResponseAction SyncStartFunction::Run() {
  SyncService* sync_service = VivaldiSyncServiceFactory::GetForProfile(
      Profile::FromBrowserContext(browser_context()));

  if (!sync_service)
    return RespondNow(NoArguments());

  sync_service->GetUserSettings()->SetSyncRequested(true);

  return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction SyncStopFunction::Run() {
  SyncService* sync_service = VivaldiSyncServiceFactory::GetForProfile(
      Profile::FromBrowserContext(browser_context()));

  if (!sync_service)
    return RespondNow(NoArguments());

  sync_service->StopAndClear();
  return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction SyncSetEncryptionPasswordFunction::Run() {
  std::unique_ptr<vivaldi::sync::SetEncryptionPassword::Params> params(
      vivaldi::sync::SetEncryptionPassword::Params::Create(args()));

  EXTENSION_FUNCTION_VALIDATE(params.get());

  VivaldiSyncServiceImpl* sync_service =
      VivaldiSyncServiceFactory::GetForProfileVivaldi(
          Profile::FromBrowserContext(browser_context()));
  if (!sync_service)
    return RespondNow(Error("Sync manager is unavailable"));

  if (!sync_service->IsEngineInitialized())
    return RespondNow(Error("Sync engine is not ready"));

  bool success = sync_service->ui_helper()->SetEncryptionPassword(
      params->password ? *params->password : std::string());

  return RespondNow(ArgumentList(
      vivaldi::sync::SetEncryptionPassword::Results::Create(success)));
}

ExtensionFunction::ResponseAction SyncBackupEncryptionTokenFunction::Run() {
  std::unique_ptr<vivaldi::sync::BackupEncryptionToken::Params> params(
      vivaldi::sync::BackupEncryptionToken::Params::Create(args()));

  EXTENSION_FUNCTION_VALIDATE(params.get());

  VivaldiSyncServiceImpl* sync_service =
      VivaldiSyncServiceFactory::GetForProfileVivaldi(
          Profile::FromBrowserContext(browser_context()));
  if (!sync_service)
    return RespondNow(Error("Sync manager is unavailable"));

  if (!sync_service->GetUserSettings()->IsEncryptEverythingEnabled())
    return RespondNow(Error("Encryption not enabled"));

  auto key = std::make_unique<std::string>(
      sync_service->ui_helper()->GetBackupEncryptionToken());

  if (key->empty()) {
    return RespondNow(ArgumentList(
        vivaldi::sync::BackupEncryptionToken::Results::Create(false)));
  }

  base::ThreadPool::PostTaskAndReplyWithResult(
      FROM_HERE, {base::MayBlock()},
      base::BindOnce(&WriteFileWrapper,
                     base::FilePath::FromUTF8Unsafe(params->target_file),
                     std::move(key)),
      base::BindOnce(&SyncBackupEncryptionTokenFunction::OnBackupDone, this));

  AddRef();
  return RespondLater();
}

void SyncBackupEncryptionTokenFunction::OnBackupDone(bool result) {
  Respond(ArgumentList(
      vivaldi::sync::BackupEncryptionToken::Results::Create(result)));
  Release();  // Balances AddRef in Run()
}

ExtensionFunction::ResponseAction SyncRestoreEncryptionTokenFunction::Run() {
  std::unique_ptr<vivaldi::sync::RestoreEncryptionToken::Params> params(
      vivaldi::sync::RestoreEncryptionToken::Params::Create(args()));

  EXTENSION_FUNCTION_VALIDATE(params.get());

  SyncService* sync_service = VivaldiSyncServiceFactory::GetForProfile(
      Profile::FromBrowserContext(browser_context()));
  if (!sync_service)
    return RespondNow(Error("Sync manager is unavailable"));

  if (!sync_service->GetUserSettings()->IsPassphraseRequired())
    return RespondNow(
        Error("Sync currently isn't requiring an encryption password"));

  auto token = std::make_unique<std::string>();
  // token_ptr is expected to be valid as long as token is valid,
  // which should be at least until OnRestoreDone is called. So, it should be
  // safe to use during base::ReadFileToString
  std::string* token_ptr = token.get();
  base::ThreadPool::PostTaskAndReplyWithResult(
      FROM_HERE, {base::MayBlock()},
      base::BindOnce(&base::ReadFileToString,
                     base::FilePath::FromUTF8Unsafe(params->source_file),
                     token_ptr),
      base::BindOnce(&SyncRestoreEncryptionTokenFunction::OnRestoreDone, this,
                     std::move(token)));

  return RespondLater();
}

void SyncRestoreEncryptionTokenFunction::OnRestoreDone(
    std::unique_ptr<std::string> token,
    bool result) {
  if (result) {
    VivaldiSyncServiceImpl* sync_service =
        VivaldiSyncServiceFactory::GetForProfileVivaldi(
            Profile::FromBrowserContext(browser_context()));
    if (!sync_service)
      return Respond(Error("Sync manager is unavailable"));
    result = sync_service->ui_helper()->RestoreEncryptionToken(*token);
  }

  Respond(ArgumentList(
      vivaldi::sync::RestoreEncryptionToken::Results::Create(result)));
}

SyncGetDefaultSessionNameFunction::SyncGetDefaultSessionNameFunction() =
    default;
SyncGetDefaultSessionNameFunction::~SyncGetDefaultSessionNameFunction() =
    default;

ExtensionFunction::ResponseAction SyncGetDefaultSessionNameFunction::Run() {
  base::PostTaskAndReplyWithResult(
      base::ThreadPool::CreateSequencedTaskRunner(
          {base::MayBlock(), base::TaskPriority::BEST_EFFORT,
           base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})
          .get(),
      FROM_HERE, base::BindOnce(&syncer::GetPersonalizableDeviceNameBlocking),
      base::BindOnce(
          &SyncGetDefaultSessionNameFunction::OnGetDefaultSessionName, this));
  return RespondLater();
}

void SyncGetDefaultSessionNameFunction::OnGetDefaultSessionName(
    const std::string& session_name) {
  Respond(ArgumentList(
      vivaldi::sync::GetDefaultSessionName::Results::Create(session_name)));
}

ExtensionFunction::ResponseAction SyncSetTypesFunction::Run() {
  std::unique_ptr<vivaldi::sync::SetTypes::Params> params(
      vivaldi::sync::SetTypes::Params::Create(args()));

  EXTENSION_FUNCTION_VALIDATE(params.get());

  SyncService* sync_service = VivaldiSyncServiceFactory::GetForProfile(
      Profile::FromBrowserContext(browser_context()));
  if (!sync_service)
    return RespondNow(Error("Sync manager is unavailable"));

  SyncAPI::GetFactoryInstance()
      ->Get(Profile::FromBrowserContext(browser_context()))
      ->StartSyncSetup(sync_service);

  syncer::UserSelectableTypeSet chosen_types;
  for (const auto& type_selection : params->types) {
    if (type_selection.enabled) {
      chosen_types.Put(
          FromVivaldiSyncDataType(type_selection.data_type).value());
    }
  }
  if (chosen_types.Has(syncer::UserSelectableType::kHistory))
    chosen_types.Put(syncer::UserSelectableType::kTabs);

  sync_service->GetUserSettings()->SetSelectedTypes(params->sync_everything,
                                                    chosen_types);

  return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction SyncGetEngineStateFunction::Run() {
  return RespondNow(ArgumentList(vivaldi::sync::GetEngineState::Results::Create(
      GetEngineData(Profile::FromBrowserContext(browser_context())))));
}

ExtensionFunction::ResponseAction SyncGetLastCycleStateFunction::Run() {
  return RespondNow(
      ArgumentList(vivaldi::sync::GetLastCycleState::Results::Create(
          GetLastCycleData(Profile::FromBrowserContext(browser_context())))));
}

ExtensionFunction::ResponseAction SyncClearDataFunction::Run() {
  VivaldiSyncServiceImpl* sync_service =
      VivaldiSyncServiceFactory::GetForProfileVivaldi(
          Profile::FromBrowserContext(browser_context()));
  if (!sync_service)
    return RespondNow(Error("Sync manager is unavailable"));

  sync_service->ClearSyncData();

  return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction SyncSetupCompleteFunction::Run() {
  SyncService* sync_service = VivaldiSyncServiceFactory::GetForProfile(
      Profile::FromBrowserContext(browser_context()));
  if (!sync_service)
    return RespondNow(Error("Sync manager is unavailable"));

  sync_service->GetUserSettings()->SetFirstSetupComplete(
      syncer::SyncFirstSetupCompleteSource::BASIC_FLOW);
  SyncAPI::GetFactoryInstance()
      ->Get(Profile::FromBrowserContext(browser_context()))
      ->SyncSetupComplete();

  return RespondNow(NoArguments());
}

}  // namespace extensions


text:
/*
 *  This file is part of the Wayback archival access software
 *   (http://archive-access.sourceforge.net/projects/wayback/).
 *
 *  Licensed to the Internet Archive (IA) by one or more individual
 *  contributors.
 *
 *  The IA licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.archive.wayback.util;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import org.archive.io.WriterPoolSettings;
import org.archive.io.arc.ARCConstants;
import org.archive.io.warc.WARCWriter;
import org.archive.io.warc.WARCWriterPoolSettings;
import org.archive.uid.RecordIDGenerator;
import org.archive.uid.UUIDGenerator;
import org.archive.util.anvl.ANVLRecord;

public class WARCHeader {
	private void writeHeaderRecord(File target, File fieldsSrc, String id)
	throws IOException {

		WARCWriter writer = null;

		BufferedOutputStream bos =
			new BufferedOutputStream(new FileOutputStream(target));

		FileInputStream is = new FileInputStream(fieldsSrc);
		ANVLRecord ar = ANVLRecord.load(is);

		List<String> metadata = new ArrayList<String>(1);
		metadata.add(ar.toString());

		writer = new WARCWriter(new AtomicInteger(),bos,target,getSettings(true, null, null, metadata));
		// Write a warcinfo record with description about how this WARC
		// was made.
		writer.writeWarcinfoRecord(target.getName(), "Made from "
				+ id + " by "
				+ this.getClass().getName());

	}
	private WARCWriterPoolSettings getSettings(final boolean isCompressed,
			final String prefix, final List<File> arcDirs, final List metadata) {
		return new WARCWriterPoolSettings() {
			public List<File> calcOutputDirs() {
				return arcDirs;
			}

			@SuppressWarnings({ "unchecked", "rawtypes" })
			public List getMetadata() {
				return metadata;
			}

			public String getPrefix() {
				return prefix;
			}

			public boolean getCompress() {
				return isCompressed;
			}

			public long getMaxFileSizeBytes() {
				return ARCConstants.DEFAULT_MAX_ARC_FILE_SIZE;
			}

			public String getTemplate() {
				return "${prefix}-${timestamp17}-${serialno}";
			}

			public boolean getFrequentFlushes() {
				return false;
			}

			public int getWriteBufferSize() {
				return 4096;
			}

			public RecordIDGenerator getRecordIDGenerator() {
				return new UUIDGenerator();
			}
		};
	}

	public static void main(String[] args) {
		if (args.length != 3) {
			System.err.println("USAGE: tgtWarc fieldsSrc id");
			System.err.println("\ttgtWarc is the path to the target WARC.gz");
			System.err.println("\tfieldsSrc is the path to the text of the record");
			System.err.println("\t\tmake sure each line is terminated by \\r\\n");
			System.err.println("\t\tand that the file ends with a blank, \\r\\n terminiated line");
			System.err.println("\tid is the XXX in:");
			System.err.println("\t\tContent-Description: Made from XXX by org.archive.wayback.util.WARCHeader");
			System.err.println("\t\tof the header record... header...");
			System.exit(1);
		}
		File target = new File(args[0]);
		File fieldSrc = new File(args[1]);
		String id = args[2];
		WARCHeader header = new WARCHeader();
		try {
			header.writeHeaderRecord(target, fieldSrc, id);
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(2);
		}
	}

}