Example #1
0
            public bool Add(Statement s)
            {
                if (domran == 1 && !(s.Object is Entity))
                {
                    return(true);
                }
                ResSet rs = (ResSet)table[s.Predicate];

                if (rs == null)
                {
                    return(true);
                }
                foreach (Entity e in RDFS.GetClosure(rs, superclasses, true))
                {
                    Statement s1 = new Statement(
                        domran == 0 ? s.Subject : (Entity)s.Object,
                        type,
                        e,
                        s.Meta);
                    if (!sink.Add(s1))
                    {
                        return(false);
                    }
                }
                return(true);
            }
Example #2
0
        private static int AboneDetecting(ResSetCollection oldItems, ResSetCollection newItems)
        {
            ResSetCollection temp = new ResSetCollection();

            for (int i = 0; i < oldItems.Count; i++)
            {
                ResSet old = oldItems[i];

                ResSet _new = newItems[i];
                temp.Add(_new);


                if (IsAboned(_new, old))
                {
                    old.IsServerAboned = true;
                    oldItems[i]        = old;
                }
            }

            X2chThreadFormatter formatter = new X2chThreadFormatter();

            string datStr = formatter.Format(temp);

            byte[] rawBytes = Encoding.GetEncoding("shift_jis").GetBytes(datStr);

            int newByteOffset = rawBytes.Length;

            // これが正しいバイトオフセットになる・・・はず。
            return(newByteOffset);
        }
Example #3
0
        /// <summary>
        /// レスを読み込む
        /// </summary>
        /// <param name="resSets"></param>
        /// <param name="byteParsed"></param>
        /// <returns></returns>
        public override int Read(ResSetCollection resSets, out int byteParsed)
        {
            if (resSets == null)
            {
                throw new ArgumentNullException("resSets");
            }
            if (!isOpen)
            {
                throw new InvalidOperationException("ストリームが開かれていません");
            }

            // バッファにデータを読み込む
            int byteCount = baseStream.Read(buffer, 0, buffer.Length);

            // 解析してコレクションに格納
            ICollection collect = dataParser.Parse(buffer, byteCount, out byteParsed);

            foreach (ResSet resSet in collect)
            {
                ResSet res = resSet;
                res.Index = index++;
                resSets.Add(res);

                if (res.Index == 1 && res.Tag != null)
                {
                    headerInfo.Subject = (string)res.Tag;
                }
            }

            // 実際に読み込まれたバイト数を計算
            position += byteCount;

            return(byteCount);
        }
Example #4
0
        static bool eq(Resource[] a, Resource[] b)
        {
            if (a == b)
            {
                return(true);
            }
            if (a == null || b == null)
            {
                return(false);
            }
            if (a.Length != b.Length)
            {
                return(false);
            }
            bool alleq = true;

            for (int i = 0; i < a.Length; i++)
            {
                if (!a[i].Equals(b[i]))
                {
                    alleq = false;
                }
            }
            if (alleq)
            {
                return(true);
            }
            ResSet xa = new ResSet(a);
            ResSet xb = new ResSet(b);

            xa.RetainAll(xb);
            return(xa.Count == xb.Count);
        }
        protected virtual ResSet ParseResSet(string[] elements)
        {
            ResSet resSet = new ResSet(-1, "[ここ壊れてます]",
                                       String.Empty, "[ここ壊れてます]", "[ここ壊れてます]");

            try
            {
                // name=0、email=1、date=2、message=3、subject=4
                resSet.Name       = elements[0];
                resSet.Email      = elements[1];
                resSet.DateString = elements[2];
                resSet.Body       = elements[3];          //HtmlTextUtility.RefRegex.Replace(elements[3], "<a href=\"../${num}\" target=\"_blank\">${ref}</a>");

                if (elements.Length >= 5 &&
                    elements[4] != String.Empty)
                {
                    resSet.Tag = elements[4];
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex);
            }

            return(resSet);
        }
        /// <summary>
        /// レスを読み込む
        /// </summary>
        /// <param name="resSets"></param>
        /// <param name="byteParsed">解析されたバイト数が格納される</param>
        /// <returns>読み込まれた総byte数を返す</returns>
        public override int Read(ResSetCollection resSets, out int byteParsed)
        {
            if (resSets == null)
            {
                throw new ArgumentNullException("resSets");
            }
            if (!isOpen)
            {
                throw new InvalidOperationException("ストリームが開かれていません");
            }

            // バッファにデータを読み込む
            int readCount = baseStream.Read(buffer, 0, buffer.Length);

            // 解析してコレクションに格納
            ResSet[] items = dataParser.Parse(buffer, readCount, out byteParsed);

            foreach (ResSet resSet in items)
            {
                ResSet res = resSet;
                res.Index = index++;
                resSets.Add(res);
            }

            // 実際に読み込まれたバイト数を計算
            position += readCount;

            return(readCount);
        }
        public static void FindMSG(SelectableSource store, Entity node, Store msg)
        {
            if (node.Uri != null)
            {
                throw new ArgumentException("node must be anonymous");
            }

            ResSet nodesSeen  = new ResSet();
            ResSet nodesToAdd = new ResSet();

            nodesToAdd.Add(node);

            while (nodesToAdd.Count > 0)
            {
                ResSet nodes = nodesToAdd;
                nodesToAdd = new ResSet();

                Sink sink = new Sink(msg, nodesToAdd);
                foreach (Entity n in nodes)
                {
                    if (nodesSeen.Contains(n))
                    {
                        continue;
                    }
                    nodesSeen.Add(n);
                    store.Select(new Statement(n, null, null, null), sink);
                    store.Select(new Statement(null, n, null, null), sink);
                    store.Select(new Statement(null, null, n, null), sink);
                }
            }
        }
Example #8
0
        private void GenPro()
        {
            DataTable Pro = _ds.Tables["Pro"];

            proset = new ProductSet();
            foreach (DataRow dr in Pro.Rows)
            {
                Product p = new Product()
                {
                    ProID       = Convert.ToInt32(dr["ID"]),
                    Description = dr["Des"].ToString(),
                    Fare        = Convert.ToDouble(dr["Fare"])
                };
                string s = dr["Res"].ToString();

                foreach (string ss in s.Split(','))
                {
                    Resource temp = ResSet.Find(i => i.ResID == Convert.ToInt32(ss));
                    if (temp != null)
                    {
                        p.Add(temp);
                    }
                }

                proset.Add(p);
            }
        }
Example #9
0
        protected virtual ResSet ParseResSet(string data)
        {
            ResSet resSet = new ResSet(-1, "[ここ壊れてます]",
                                       String.Empty, "[ここ壊れてます]", "[ここ壊れてます]");

            Match m = BodyRegex.Match(data);

            if (m.Success)
            {
                int index;
                Int32.TryParse(m.Groups["num"].Value, out index);

                resSet.Index      = index;
                resSet.DateString = m.Groups["date"].Value.Trim();
                resSet.Name       = m.Groups["name"].Value;
                resSet.Body       = m.Groups["body"].Value;
                resSet.Email      = m.Groups["email"].Value;

                // 日付の改行を削除
                resSet.DateString = resSet.DateString.Replace("\n", "");

                // 本文のリンクを削除し、レス参照にリンクを張る
                resSet.Body = AHrefRegex.Replace(resSet.Body, String.Empty);
                //resSet.Body = HtmlTextUtility.RefRegex.Replace(resSet.Body, "<a href=\"/${num}\" target=\"_blank\">${ref}</a>");
            }

            return(resSet);
        }
Example #10
0
        static Entity[] GetClosure(Resource[] starts, Hashtable table)
        {
            ResSet ret   = new ResSet();
            ResSet toadd = new ResSet(starts);

            while (toadd.Count > 0)
            {
                ResSet newadd = new ResSet();

                foreach (Resource e in toadd)
                {
                    if (!(e is Entity))
                    {
                        continue;
                    }
                    if (ret.Contains(e))
                    {
                        continue;
                    }
                    ret.Add(e);
                    if (table.ContainsKey(e))
                    {
                        newadd.AddRange((ResSet)table[e]);
                    }
                }

                toadd.Clear();
                toadd.AddRange(newadd);
            }
            return(ret.ToEntityArray());
        }
Example #11
0
 static Entity[] GetClosure(ResSet starts, Hashtable table)
 {
     if (starts == null)
     {
         return(null);
     }
     return(GetClosure(starts.ToArray(), table));
 }
Example #12
0
 static Entity[] GetClosure(ResSet starts, Hashtable table, bool includeStarts)
 {
     if (starts == null)
     {
         return(null);
     }
     return(GetClosure(starts.ToArray(), table, includeStarts));
 }
Example #13
0
 void Add(int varIndex, Resource binding)
 {
     if (Bindings[varIndex] == null)
     {
         Bindings[varIndex] = new ResSet();
     }
     Bindings[varIndex].Add(binding);
 }
Example #14
0
            private void CalcInterval()
            {
                int length = client.ResSets.Count;

                if (length == 0)
                {
                    timer.Interval = 30000;
                    return;
                }
                try
                {
                    /*
                     * int count = Math.Min(10, length);
                     * TimeSpan span = TimeSpan.Zero;
                     * ResSet res = client.ResSets[length - count];
                     * Match m = daterex.Match(res.DateString);
                     * if (m.Success)
                     * {
                     *      string dateStr = m.Groups["d"].Value + m.Groups["t"].Value;
                     *      DateTime dt;
                     *      if (DateTime.TryParseExact(dateStr, "yyyy/MM/ddHH:mm:ss", null, DateTimeStyles.None, out dt))
                     *      {
                     *              span = DateTime.Now - dt;
                     *      }
                     * }
                     *
                     * int averageSeconds = (int)span.TotalSeconds / count;
                     * timer.Interval = Math.Max(10000, averageSeconds * 1000);*/

                    DateTime[] dt = new DateTime[3];
                    dt[0] = dt[1] = dt[2] = DateTime.Now;

                    for (int i = 1; i <= 2 && (length - i) >= 0; i++)
                    {
                        ResSet   res = client.ResSets[length - i];
                        DateTime ret;

                        Match m = daterex.Match(res.DateString);
                        if (m.Success)
                        {
                            DateTime.TryParseExact(m.Groups["d"].Value + m.Groups["t"].Value,
                                                   "yyyy/MM/ddHH:mm:ss", null, DateTimeStyles.None, out ret);

                            if (ret != DateTime.MinValue)
                            {
                                dt[i] = ret;
                            }
                        }
                    }

                    TimeSpan span    = CalcAverageInterval(dt[0], dt[1], dt[2]);
                    int      seconds = (int)Math.Min(span.TotalSeconds, 2000000);
                    timer.Interval = Math.Max(10000, seconds * 1000);
                }
                catch
                {
                }
            }
Example #15
0
        private void GenRes()
        {
            DataTable Res = _ds.Tables["Res"];

            MRS = new MetaResourceSet()
            {
                ResSet  = new ResourceSet(),
                SeatSet = new SeatSet()
            };
            InitState = new MetaResouceState();
            string      temp     = "";
            List <Seat> tempSeat = null;

            foreach (DataRow dr in Res.Rows)
            {
                Resource r = new Resource()
                {
                    ResID       = Convert.ToInt32(dr["ID"]),
                    Description = dr["Des"].ToString(),
                    Tag         = dr["Tag"].ToString()
                };
                ResSet.Add(r);
                InitState.ResDic.Add(r, 0);
                int num = Convert.ToInt32(dr["Cap"]);
                if (temp != r.Tag)
                {
                    tempSeat = new List <Seat>();
                    for (int i = MRS.SeatSet.Count; i < MRS.SeatSet.Count + num; i++)
                    {
                        tempSeat.Add(new Seat()
                        {
                            SeatID = i, Tag = r.Tag, IDinTrain = i - MRS.SeatSet.Count
                        });
                    }
                    MRS.SeatSet.AddRange(tempSeat);
                }
                for (int i = 0; i < num; i++)
                {
                    MetaResource mr = new MetaResource()
                    {
                        Name     = r.ResID + "_" + i,
                        ResID    = r.ResID,
                        SeatID   = i,
                        Resource = r,
                        Seat     = tempSeat[i]
                    };
                    InitState.MetaResDic.Add(mr, false);
                    MRS.Add(mr);
                    r.MetaResList.Add(mr);
                    tempSeat[i].MetaResList.Add(mr);
                }
                temp = r.Tag;
            }
            InitState.UpdateResDic();
        }
        private ResSetCollection GetResCollection(XmlDocument doc, XmlNode resset)
        {
            ResSetCollection collection = new ResSetCollection();

            foreach (XmlNode child in resset.SelectNodes("res"))
            {
                XmlNode num = child.Attributes.GetNamedItem("num");
                if (num == null)
                {
                    throw new ConvertException("num属性が存在しません");
                }

                // state属性は無視
                // ...

                XmlNode name = child.SelectSingleNode("name");
                if (name == null)
                {
                    throw new ConvertException("<name>要素が存在しません");
                }

                XmlNode email = child.SelectSingleNode("email");
                if (email == null)
                {
                    throw new ConvertException("<email>要素が存在しません");
                }

                XmlNode timestamp = child.SelectSingleNode("timestamp");
                if (timestamp == null)
                {
                    throw new ConvertException("<timestamp>要素が存在しません");
                }

                XmlNode message = child.SelectSingleNode("message");
                if (message == null)
                {
                    throw new ConvertException("<message>要素が存在しません");
                }

                int index;
                Int32.TryParse(num.Value, out index);

                ResSet res = new ResSet(
                    index,
                    name.InnerText,
                    email.InnerText,
                    timestamp.InnerText,
                    message.InnerText);

                collection.Add(res);
            }

            return(collection);
        }
Example #17
0
        void AddRelation(Entity a, Entity b, Hashtable h)
        {
            ResSet r = (ResSet)h[a];

            if (r == null)
            {
                r    = new ResSet();
                h[a] = r;
            }
            r.Add(b);
        }
Example #18
0
 void Set(int varIndex, Resource binding)
 {
     if (Bindings[varIndex] == null)
     {
         Bindings[varIndex] = new ResSet();
     }
     else
     {
         Bindings[varIndex].Clear();
     }
     Bindings[varIndex].Add(binding);
 }
        /// <summary>
        /// レスを読み込む
        /// </summary>
        /// <param name="resSets"></param>
        /// <param name="byteParsed"></param>
        /// <returns></returns>
        public override int Read(ResSetCollection resSets, out int byteParsed)
        {
            if (resSets == null)
            {
                throw new ArgumentNullException("resSets");
            }
            if (!isOpen)
            {
                throw new InvalidOperationException("ストリームが開かれていません");
            }

            // バッファにデータを読み込む
            int byteCount = baseStream.Read(buffer, 0, buffer.Length);

            // あぼーんチェック
            if (aboneCheck && byteCount > 0)
            {
                if (buffer[0] != '\n')
                {
                    OnABone();
                    byteParsed = 0;

                    headerInfo.ETag         = String.Empty;
                    headerInfo.LastModified = DateTime.MinValue;

                    return(-1);
                }

                buffer     = RemoveHeader(buffer, byteCount, 1);
                byteCount -= 1;
                aboneCheck = false;
            }

            // 解析してコレクションに格納
            ICollection collect = dataParser.Parse(buffer, byteCount, out byteParsed);

            foreach (ResSet resSet in collect)
            {
                ResSet res = resSet;
                res.Index = index++;
                resSets.Add(res);

                if (res.Index == 1 && res.Tag != null)
                {
                    headerInfo.Subject = (string)res.Tag;
                }
            }

            // 実際に読み込まれたバイト数を計算
            position += byteCount;

            return(byteCount);
        }
Example #20
0
        private static bool IsAboned(ResSet resNew, ResSet resOld)
        {
            string[] aboneStr = { "あぼーん", "うふ〜ん" };

            foreach (string s in aboneStr)
            {
                if (resNew.DateString.Trim() == s && resOld.DateString != s)
                {
                    return(true);
                }
            }
            return(false);
        }
        /// <summary>
        /// レスを読み込む
        /// </summary>
        /// <param name="resSets"></param>
        /// <param name="byteParsed"></param>
        /// <returns></returns>
        public override int Read(ResSetCollection resSets, out int byteParsed)
        {
            if (resSets == null)
            {
                throw new ArgumentNullException("resSets");
            }
            if (!isOpen)
            {
                throw new InvalidOperationException("ストリームが開かれていません");
            }

            // バッファにデータを読み込む
            int byteCount = baseStream.Read(buffer, 0, buffer.Length);

            // 解析してコレクションに格納
            ICollection collect = dataParser.Parse(buffer, byteCount, out byteParsed);

            foreach (ResSet resSet in collect)
            {
                ResSet res = resSet;
                if (res.Index <= 0)
                {
                    res.Index = index++;
                }

                // JBBSあぼーん対策
                //int aboneCount = (res.Index - prevIndex) - 1; // 直前のレス番号と比較し、飛んでいるレス数を求める
                //if (prevIndex != -1 && aboneCount > 1)
                //{
                //    // まちBBS、JBBSではレスをdat自体から削除するあぼーんがあるため、
                //    // 解析の際にレス番号が飛んでしまいレス番号が狂ってしまう。
                //    // なのでダミーのあぼーんレスを挿入しておく
                //    for (int i = 0; i < aboneCount; i++)
                //        resSets.Add(ResSet.ABoneResSet);
                //}
                prevIndex = res.Index;

                resSets.Add(res);

                if (res.Index == 1 && res.Tag != null)
                {
                    headerInfo.Subject = (string)res.Tag;
                }
            }

            // 実際に読み込まれたバイト数を計算
            position += byteCount;

            return(byteCount);
        }
Example #22
0
        protected override ResSet[] ParseData(string dataText)
        {
            if (dataText == null)
            {
                throw new ArgumentNullException("dataText");
            }

            //string[] lines = Regex.Split(dataText, "\r\n|\r|\n");
            List <ResSet> list = new List <ResSet>(300);
            int           begin = 0, index;

            while ((index = searcher.Search(dataText, begin)) != -1)
            {
                string lineData = dataText.Substring(begin, index - begin);
                begin = index + searcher.Pattern.Length;

                ResSet resSet = new ResSet(-1, "[ここ壊れてます]",
                                           String.Empty, "[ここ壊れてます]", "[ここ壊れてます]");

                string[] elements = Regex.Split(lineData, "<>");

                if (elements.Length >= 4)
                {
                    try {
                        // IDを取得
                        Match  idmatch = ZetaIDRegex.Match(elements[2]);
                        string id      = idmatch.Success ? idmatch.Groups["id"].Value : "";

                        // name=0、email=1、date=2、message=3、subject=4
                        resSet.ID         = id;
                        resSet.Name       = elements[0];
                        resSet.Email      = elements[1];
                        resSet.DateString = elements[2];
                        resSet.Body       = elements[3];

                        if (elements.Length >= 5 &&
                            elements[4] != String.Empty)
                        {
                            resSet.Tag = elements[4];
                        }
                        list.Add(resSet);
                    }
                    catch (Exception ex) {
                        System.Diagnostics.Debug.Write(ex);
                    }
                }
            }

            return(list.ToArray());
        }
Example #23
0
        void AddRelation(Entity a, Entity b, Hashtable h, bool incself)
        {
            ResSet r = (ResSet)h[a];

            if (r == null)
            {
                r    = new ResSet();
                h[a] = r;
                if (incself)
                {
                    r.Add(a);
                }
            }
            r.Add(b);
        }
Example #24
0
        void RewriteGraph(Statement[] graph, SemWeb.Query.QueryOptions options, out Statement[] graph2, out SemWeb.Query.QueryOptions options2, SemWeb.Query.QueryResultSink sink)
        {
            graph2   = new Statement[graph.Length];
            options2 = new SemWeb.Query.QueryOptions();

            options2.DistinguishedVariables = options.DistinguishedVariables;
            options2.Limit = options.Limit;
            options2.VariableKnownValues    = (options.VariableKnownValues == null ? new VarKnownValuesType() : new VarKnownValuesType(options.VariableKnownValues));
            options2.VariableLiteralFilters = options.VariableLiteralFilters;

            for (int i = 0; i < graph.Length; i++)
            {
                graph2[i] = graph[i];

                //ResSet subj = GetQueryRes(graph[i], 0, options);
                ResSet pred = GetQueryRes(graph[i], 1, options);
                ResSet obj  = GetQueryRes(graph[i], 2, options);

                if (pred.Count == 1 && pred.Contains(type))
                {
                    // in an ?x rdf:type ___ query, replace ___ with the subclass closure of ___.
                    if (obj.Count > 0)
                    {
                        Entity[] sc = GetClosure(obj, subclasses, true);
                        if (sc.Length != obj.Count && sink != null)
                        {
                            sink.AddComments("Expanding object of " + graph[i] + " with subclass closure to [" + ToString(sc) + "]");
                        }
                        SetQueryRes(ref graph2[i], 2, options2, sc);
                    }
                }

                // expand properties into subproperties after the above tests,
                // because we want to be sure the property was originally
                // just one of the recognized properties

                if (pred.Count > 0)
                {
                    Entity[] pc = GetClosure(pred, subprops, true);
                    SetQueryRes(ref graph2[i], 1, options2, pc);
                    if (pc.Length != pred.Count && sink != null)
                    {
                        sink.AddComments("Expanding predicate of " + graph[i] + " with subproperty closure to [" + ToString(pc) + "]");
                    }
                }
            }
        }
Example #25
0
        /// <summary>
        /// resSetを書式化して文字列に変換
        /// </summary>
        /// <param name="resSet"></param>
        /// <returns></returns>
        public override string Format(ResSet resSet)
        {
            StringBuilder sb = new StringBuilder(512);

            sb.Append(resSet.Name);
            sb.Append("<>");
            sb.Append(resSet.Email);
            sb.Append("<>");
            sb.Append(resSet.DateString);
            sb.Append("<>");
            sb.Append(resSet.Body);
            sb.Append("<>");
            sb.Append(resSet.Tag is String ? (String)resSet.Tag : String.Empty);
            sb.Append("\n");

            return(sb.ToString());
        }
Example #26
0
        ResSet GetQueryRes(Statement s, int i, SemWeb.Query.QueryOptions options)
        {
            ResSet   ret = new ResSet();
            Resource r   = s.GetComponent(i);

            if (r == null)
            {
                return(ret);
            }

            if (!(r is Variable))
            {
                ret.Add(r);
            }

            if (options.VariableKnownValues != null && r is Variable
#if !DOTNET2
                && options.VariableKnownValues.Contains((Variable)r))
            {
Example #27
0
        protected override ResSet ParseResSet(string[] elements)
        {
            ResSet resSet = new ResSet(-1, "[ここ壊れてます]",
                                       String.Empty, "[ここ壊れてます]", "[ここ壊れてます]");

            // [レス番号]<>[名前]<>[メール]<>[日付]<>[本文]<>[スレッドタイトル]<>[ID]

            int index;

            Int32.TryParse(elements[0], out index);

            resSet.Index      = index;
            resSet.Name       = elements[1];
            resSet.Email      = elements[2];
            resSet.DateString = String.Concat(elements[3], " ID:", elements[6]);
            resSet.Body       = elements[4];
            resSet.Tag        = elements[5];
            resSet.ID         = elements[6];

            return(resSet);
        }
        protected override ResSet[] ParseData(string data)
        {
            MatchCollection matches = Pattern.Matches(data);
            List <ResSet>   items   = new List <ResSet>();

            foreach (Match m in matches)
            {
                int index;
                Int32.TryParse(m.Groups["index"].Value, out index);

                ResSet res = new ResSet(
                    index,
                    m.Groups["name"].Value,
                    m.Groups["email"].Value,
                    m.Groups["dateid"].Value,
                    m.Groups["body"].Value);

                items.Add(res);
            }
            ;

            return(items.ToArray());
        }
Example #29
0
        private ResSetCollection ReadFile(string filePath, bool gzip)
        {
            ResSetCollection resCollection = new ResSetCollection();
            Stream           stream        = StreamCreator.CreateReader(filePath, gzip);
            ThreadParser     dataParser    = new X2chThreadParser();

            try {
                byte[] buffer = new byte[10240];
                int    readCount = 0, index = 1;

                do
                {
                    // バッファにデータを読み込む
                    readCount = stream.Read(buffer, 0, buffer.Length);
                    int parsed;

                    // 解析してコレクションに格納
                    ICollection collect = dataParser.Parse(buffer, readCount, out parsed);

                    foreach (ResSet resSet in collect)
                    {
                        ResSet res = resSet;
                        res.Index = index++;

                        resCollection.Add(res);
                    }
                } while (readCount != 0);
            }
            finally {
                if (stream != null)
                {
                    stream.Close();
                }
            }

            return(resCollection);
        }
Example #30
0
            public void Select(SelectFilter filter, StatementSink result)
            {
                ResSet
                    s = filter.Subjects == null ? null : new ResSet(filter.Subjects),
                    p = filter.Predicates == null ? null : new ResSet(filter.Predicates),
                    o = filter.Objects == null ? null : new ResSet(filter.Objects),
                    m = filter.Metas == null ? null : new ResSet(filter.Metas);

                foreach (Statement st in statements)
                {
                    if (s != null && !s.Contains(st.Subject))
                    {
                        continue;
                    }
                    if (p != null && !p.Contains(st.Predicate))
                    {
                        continue;
                    }
                    if (o != null && !o.Contains(st.Object))
                    {
                        continue;
                    }
                    if (m != null && !m.Contains(st.Meta))
                    {
                        continue;
                    }
                    if (filter.LiteralFilters != null && !LiteralFilter.MatchesFilters(st.Object, filter.LiteralFilters, this))
                    {
                        continue;
                    }
                    if (!result.Add(st))
                    {
                        return;
                    }
                }
            }