<commit_before>/**
 * Copyright 2009 Google Inc.
 *
 * Licensed 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 com.google.wave.api.data;

import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.wave.api.Attachment;
import com.google.wave.api.Element;
import com.google.wave.api.ElementType;
import com.google.wave.api.FormElement;
import com.google.wave.api.Gadget;
import com.google.wave.api.Image;
import com.google.wave.api.Installer;
import com.google.wave.api.Line;

import org.waveprotocol.wave.model.conversation.Blips;
import org.waveprotocol.wave.model.document.Doc;
import org.waveprotocol.wave.model.document.Doc.E;
import org.waveprotocol.wave.model.document.Doc.N;
import org.waveprotocol.wave.model.document.Document;
import org.waveprotocol.wave.model.document.util.LineContainers;
import org.waveprotocol.wave.model.document.util.XmlStringBuilder;
import org.waveprotocol.wave.model.id.IdConstants;
import org.waveprotocol.wave.model.wave.Wavelet;

import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Class to support serializing Elements from and to XML.
 *
 *
 */
public abstract class ElementSerializer {

  // Two maps to easily look up what to serialize
  private static final Map<ElementType, ElementSerializer> typeToSerializer = Maps.newHashMap();
  private static final Map<String, ElementSerializer> tagToSerializer = Maps.newHashMap();

  private static final String CAPTION_TAG = "w:caption";
  private static final String CLICK_TAG = "w:click";
  private static final String ATTACHMENT_STR = "attachment";
  private static final String CAPTION_STR = "caption";

  /** The attachment URL regular expression */
  private static final Pattern ATTACHMENT_URL_PATTERN = Pattern.compile(
      "attachment_url\\\"\\ value\\=\\\"([^\\\"]*)\\\"");

  /** The attachment MIME type regular expression */
  private static final Pattern MIME_TYPE_PATTERN = Pattern.compile(
      "mime_type\\\"\\ value\\=\\\"([^\\\"]*)\\\"");

  /** Attachment Download Host URL */
  private static String attachmentDownloadHostUrl = "";

  public static void setAttachmentDownloadHostUrl(String attachmentDownloadHostUrl){
    ElementSerializer.attachmentDownloadHostUrl = attachmentDownloadHostUrl;
  }

  public static XmlStringBuilder apiElementToXml(Element e) {
    ElementSerializer serializer = typeToSerializer.get(e.getType());
    if (serializer == null) {
      return null;<commit_msg>Build fix: removes two more uses of 'w:'<commit_after>/**
 * Copyright 2009 Google Inc.
 *
 * Licensed 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 com.google.wave.api.data;

import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.wave.api.Attachment;
import com.google.wave.api.Element;
import com.google.wave.api.ElementType;
import com.google.wave.api.FormElement;
import com.google.wave.api.Gadget;
import com.google.wave.api.Image;
import com.google.wave.api.Installer;
import com.google.wave.api.Line;

import org.waveprotocol.wave.model.conversation.Blips;
import org.waveprotocol.wave.model.document.Doc;
import org.waveprotocol.wave.model.document.Doc.E;
import org.waveprotocol.wave.model.document.Doc.N;
import org.waveprotocol.wave.model.document.Document;
import org.waveprotocol.wave.model.document.util.LineContainers;
import org.waveprotocol.wave.model.document.util.XmlStringBuilder;
import org.waveprotocol.wave.model.id.IdConstants;
import org.waveprotocol.wave.model.wave.Wavelet;

import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Class to support serializing Elements from and to XML.
 *
 *
 */
public abstract class ElementSerializer {

  // Two maps to easily look up what to serialize
  private static final Map<ElementType, ElementSerializer> typeToSerializer = Maps.newHashMap();
  private static final Map<String, ElementSerializer> tagToSerializer = Maps.newHashMap();

  private static final String CAPTION_TAG = "caption";
  private static final String CLICK_TAG = "click";
  private static final String ATTACHMENT_STR = "attachment";
  private static final String CAPTION_STR = "caption";

  /** The attachment URL regular expression */
  private static final Pattern ATTACHMENT_URL_PATTERN = Pattern.compile(
      "attachment_url\\\"\\ value\\=\\\"([^\\\"]*)\\\"");

  /** The attachment MIME type regular expression */
  private static final Pattern MIME_TYPE_PATTERN = Pattern.compile(
      "mime_type\\\"\\ value\\=\\\"([^\\\"]*)\\\"");

  /** Attachment Download Host URL */
  private static String attachmentDownloadHostUrl = "";

  public static void setAttachmentDownloadHostUrl(String attachmentDownloadHostUrl){
    ElementSerializer.attachmentDownloadHostUrl = attachmentDownloadHostUrl;
  }

  public static XmlStringBuilder apiElementToXml(Element e) {
    ElementSerializer serializer = typeToSerializer.get(e.getType());
    if (serializer == null) {
      return null;
{'fraction_non_alphanumeric': 0.11005158668125684, 'fraction_numerical': 0.002501172424574019, 'mean_word_length': 4.487135506003431, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4886939', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1787, 'n_words': 514}