<commit_before>/*
 * Copyright 2014 OpenMarket Ltd
 * Copyright 2017 Vector Creations Ltd
 * Copyright 2018 New Vector Ltd
 *
 * 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 org.matrix.androidsdk.data;

import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;

import org.matrix.androidsdk.MXDataHandler;
import org.matrix.androidsdk.call.MXCallsManager;
import org.matrix.androidsdk.data.store.IMXStore;
import org.matrix.androidsdk.rest.callback.ApiCallback;
import org.matrix.androidsdk.rest.callback.SimpleApiCallback;
import org.matrix.androidsdk.rest.model.Event;
import org.matrix.androidsdk.rest.model.PowerLevels;
import org.matrix.androidsdk.rest.model.RoomCreateContent;
import org.matrix.androidsdk.rest.model.RoomMember;
import org.matrix.androidsdk.rest.model.RoomPinnedEventsContent;
import org.matrix.androidsdk.rest.model.RoomTombstoneContent;
import org.matrix.androidsdk.rest.model.User;
import org.matrix.androidsdk.rest.model.pid.RoomThirdPartyInvite;
import org.matrix.androidsdk.util.JsonUtils;
import org.matrix.androidsdk.util.Log;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * The state of a room.
 */
public class RoomState implements Externalizable {
    private static final String LOG_TAG = RoomState.class.getSimpleName();
    private static final long serialVersionUID = -6019932024524988201L;

    public static final String DIRECTORY_VISIBILITY_PRIVATE = "private";
    public static final String DIRECTORY_VISIBILITY_PUBLIC = "public";

    public static final String JOIN_RULE_PUBLIC = "public";
    public static final String JOIN_RULE_INVITE = "invite";

    /**
     * room access is granted to guests
     **/
    public static final String GUEST_ACCESS_CAN_JOIN = "can_join";
    /**
     * room access is denied to guests
     **/
    public static final String GUEST_ACCESS_FORBIDDEN = "forbidden";

    public static final String HISTORY_VISIBILITY_SHARED = "shared";
    public static final String HISTORY_VISIBILITY_INVITED = "invited";
    public static final String HISTORY_VISIBILITY_JOINED = "joined";
    public static final String HISTORY_VISIBILITY_WORLD_READABLE = "world_readable";


    // Public members used for JSON mapping

    // The room ID
    public String roomId;

    // The power level of room members
    private PowerLevels powerLevels;

    // The aliases
    public List<String> aliases;

    // The room aliases. The key is the domain.
    private Map<String, Event> mRoomAliases = new HashMap<>();

    // the aliases are defined for each home server url
    private Map<String, List<String>> mAliasesByDomain = new HashMap<>();

    // merged from mAliasesByHomeServerUrl
    private List<String> mMergedAliasesList;

    //
    private Map<String, List<Event>> mStateEvents = new HashMap<>();

    // The canonical alias of the room
    @SerializedName("canonical_alias")
    private String canonicalAlias;

    // The name of the room as provided by the home server.
    public String name;

    // The topic of the room.
    public String topic;

    // The tombstone content if the room has been killed
    private RoomTombstoneContent mRoomTombstoneContent;

    // The avatar url of the room.
    public String url;
    public String avatar_url;

    // the room create content
    private RoomCreateContent mRoomCreateContent;

    // the room pinned events content
    @Nullable
    private RoomPinnedEventsContent mRoomPinnedEventsContent;

    // the join rule
    public String join_rule;

    /**
     * the guest access policy of the room
     **/
    public String guest_access;<commit_msg>Fix issue with canonical alias<commit_after>/*
 * Copyright 2014 OpenMarket Ltd
 * Copyright 2017 Vector Creations Ltd
 * Copyright 2018 New Vector Ltd
 *
 * 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 org.matrix.androidsdk.data;

import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;

import org.matrix.androidsdk.MXDataHandler;
import org.matrix.androidsdk.call.MXCallsManager;
import org.matrix.androidsdk.data.store.IMXStore;
import org.matrix.androidsdk.rest.callback.ApiCallback;
import org.matrix.androidsdk.rest.callback.SimpleApiCallback;
import org.matrix.androidsdk.rest.model.Event;
import org.matrix.androidsdk.rest.model.PowerLevels;
import org.matrix.androidsdk.rest.model.RoomCreateContent;
import org.matrix.androidsdk.rest.model.RoomMember;
import org.matrix.androidsdk.rest.model.RoomPinnedEventsContent;
import org.matrix.androidsdk.rest.model.RoomTombstoneContent;
import org.matrix.androidsdk.rest.model.User;
import org.matrix.androidsdk.rest.model.pid.RoomThirdPartyInvite;
import org.matrix.androidsdk.util.JsonUtils;
import org.matrix.androidsdk.util.Log;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * The state of a room.
 */
public class RoomState implements Externalizable {
    private static final String LOG_TAG = RoomState.class.getSimpleName();
    private static final long serialVersionUID = -6019932024524988201L;

    public static final String DIRECTORY_VISIBILITY_PRIVATE = "private";
    public static final String DIRECTORY_VISIBILITY_PUBLIC = "public";

    public static final String JOIN_RULE_PUBLIC = "public";
    public static final String JOIN_RULE_INVITE = "invite";

    /**
     * room access is granted to guests
     **/
    public static final String GUEST_ACCESS_CAN_JOIN = "can_join";
    /**
     * room access is denied to guests
     **/
    public static final String GUEST_ACCESS_FORBIDDEN = "forbidden";

    public static final String HISTORY_VISIBILITY_SHARED = "shared";
    public static final String HISTORY_VISIBILITY_INVITED = "invited";
    public static final String HISTORY_VISIBILITY_JOINED = "joined";
    public static final String HISTORY_VISIBILITY_WORLD_READABLE = "world_readable";


    // Public members used for JSON mapping

    // The room ID
    public String roomId;

    // The power level of room members
    private PowerLevels powerLevels;

    // The aliases
    public List<String> aliases;

    // The room aliases. The key is the domain.
    private Map<String, Event> mRoomAliases = new HashMap<>();

    // the aliases are defined for each home server url
    private Map<String, List<String>> mAliasesByDomain = new HashMap<>();

    // merged from mAliasesByHomeServerUrl
    private List<String> mMergedAliasesList;

    //
    private Map<String, List<Event>> mStateEvents = new HashMap<>();

    // The canonical alias of the room. Keep it public for Gson, because private fields are excluded.
    @SerializedName("alias")
    public String canonicalAlias;

    // The name of the room as provided by the home server.
    public String name;

    // The topic of the room.
    public String topic;

    // The tombstone content if the room has been killed
    private RoomTombstoneContent mRoomTombstoneContent;

    // The avatar url of the room.
    public String url;
    public String avatar_url;

    // the room create content
    private RoomCreateContent mRoomCreateContent;

    // the room pinned events content
    @Nullable
    private RoomPinnedEventsContent mRoomPinnedEventsContent;

    // the join rule
    public String join_rule;

    /**
     * the guest access policy of the room
     **/
    public String guest_access;
{'fraction_non_alphanumeric': 0.07933681985089573, 'fraction_numerical': 0.007789028596862134, 'mean_word_length': 3.8715447154471545, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '258061', 'n_tokens_mistral': 2638, 'n_tokens_neox': 2497, 'n_words': 821}