internal Entry[] ToArray()
 {
     Entry[] ent = new Entry[this.set.Values.Count];
     int i = 0;
     foreach (Entry e in this.set.Values)
         ent[i++] = e;
     return ent;
 }
        public void AddEntry(Entry ent)
        {
            string key = ent.Key;
            if (this.set.ContainsKey(key))
                throw new BibException(string.Format("Cannot add given field; {0} already exists", key));

            this.set.Add(key, ent);
        }
示例#3
0
        void Thesis_Masters_PhD(StreamWriter sw, Entry ent)
        {
            string author = ent.Get("author", null);
            if (string.IsNullOrEmpty(author))
                author = "??????????????????????";

            // authors
            sw.WriteLine(@"{{\sc {0}}}: ", FormatNames(author, true));

            // issu and title
            sw.WriteLine(@"\newblock {{{0}}}.", ent.Get("title", Error("title")));

            // university and year
            sw.WriteLine(@"\newblock {{{0}, {1}}}.", ent.Get("school", Error("school")), ent.Get("year", Error("year")));
        }
示例#4
0
        private Entry ReadBibtexEntry()
        {
            //@INPROCEEDINGS{DBLP:conf/ipcv/Shamir06,
            //  author = {Lior Shamir},
            //  title = {Human Perception-based Color Segmentation Using Fuzzy Logic},
            //  booktitle = {IPCV},
            //  year = {2006},
            //  pages = {496-502},
            //  bibsource = {DBLP, http://dblp.uni-trier.de},
            //  crossref = {DBLP:conf/ipcv/2006-2},
            //}

            string entry_type = this.ReadIdentifier().ToLower().Trim();
            this.ReadWhiteSpace();

            if (entry_type.ToLower() == "comment")
            {
                // comment entry is generated by the JabRef editor. Ignore this
                string content = this.ReadBetweenBraces('{', '}').Trim();
                return null;
            }

            this.MatchChar('{');
            this.ReadWhiteSpace();

            // get bibkey
            string bibkey = this.ReadUntilChar(',').Trim();
            this.ReadChar(); // ,

            Entry ent = new Entry(entry_type, bibkey);

            // read all values
            while (true)
            {
                this.ReadWhiteSpace();
                string name = this.ReadIdentifier();

                this.ReadWhiteSpace();
                this.MatchChar('=');

                this.ReadWhiteSpace();
                int ch = this.PeekChar();
                string value = string.Empty;
                if (ch == '{')
                {
                    // this part is probably highly incompatible with bibtex formats.
                    // However when using JabRef as citation manager, it normalizes the content so this
                    // code should (i hope) run correctly
                    value = this.ReadBetweenBraces('{', '}').Trim();
                }
                else
                    if (ch == '"')
                    value = this.ReadAsString();
                else
                {
                    this.ReadWhiteSpace();
                    value = this.ReadUntilChar(',').Trim();
                    this.MatchChar(',');
                }
                ent.AddField(name, value);

                this.ReadWhiteSpace();
                ch = this.PeekChar();
                if (ch == ',')
                {
                    this.ReadChar();
                    // nastepna pozycja
                }
                else
                    if (ch == '}')
                {
                    // koniec bloku
                    this.ReadChar();
                    break;
                }
            }

            return ent;
        }
示例#5
0
        private void Patent(StreamWriter sw, Entry ent)
        {
            string author = ent.Get("author", null);
            if (string.IsNullOrEmpty(author))
                author = "??????????????????????";

            // authors
            sw.WriteLine(@"{{\sc {0}}}: ", FormatNames(author, true));

            // number and title
            sw.WriteLine(@"\newblock {{{0}: {1}.}}", ent.Get("number", Error("number")), ent.Get("title", Error("title")));

            // place of publication and the name of the publisher
            sw.WriteLine(GenerateBlock(ent.Get("publisher", ""), ent.Get("address", ""), ent.Get("year", "")));
        }
示例#6
0
        void Online(StreamWriter sw, Entry ent)
        {
            // string l = "";

            string auth = "";
            if (ent.Get("author", null) != null)
                auth = FormatNames(ent.Get("author", null), true);
            else
                auth = ent.Get("organization", Error("organizatio/author"));

            sw.WriteLine(@"{{\sc {0}}}: {1}.", auth, ent.Get("title", ""));
            sw.WriteLine(@"\newblock {{{0}.}}", ent.Get("url", ""));

            if (ent.HasField("title") && ent.HasField("organization"))
                sw.WriteLine(@"\newblock {{{0}.}}", ent.Get("organization", ""));

            if (ent.HasField("note"))
                sw.WriteLine(@"\newblock {{{0}.}}", ent.Get("note", ""));
        }
示例#7
0
        void Manual(StreamWriter sw, Entry ent)
        {
            string l = "";
            l += AddIfNotEmpty(ent.Get("note", null), " ");
            l += (ent.Get("title", Error("title")));

            sw.WriteLine(@"\newblock {{{0}}}.", l);
            sw.WriteLine(GenerateBlock(ent.Get("organization", ""), ent.Get("year", "")));
        }
示例#8
0
        private void InCollection(StreamWriter sw, Entry ent)
        {
            string author = ent.Get("author", null);
            if (string.IsNullOrEmpty(author))
                author = "??????????????????????";

            // authors
            sw.WriteLine(@"{{\sc {0}}}: ", FormatNames(author, true));

            // title
            sw.WriteLine(@"\newblock {{{0}.}}", ent.Get("title", Error("title")));

            // book - editors/authors
            string editor = "";
            if (ent.HasField("editor"))
                editor = @"{\sc " + FormatNames(ent.Get("editor", null), true) + "}, ed. ";
            else
                editor = Error("editor") + " ";

            sw.WriteLine(@"\newblock {{W: {0}{1}.}}", editor, Italicize(ent.Get("booktitle", Error("booktitle"))));

            // place of publication and the name of the publisher
            sw.WriteLine(GenerateBlock(ent.Get("publisher", ""), ent.Get("address", ""), ent.Get("year", "")));

            // pages
            sw.WriteLine(@"\newblock {{str. {0}}}.", ent.Get("pages", Error("pages")));
        }
示例#9
0
        private void Conference_InProceedings(StreamWriter sw, Entry ent)
        {
            string author = ent.Get("author", null);
            if (string.IsNullOrEmpty(author))
                author = "??????????????????????";

            // authors
            //sw.WriteLine(@"{{#{2}#}} {{\sc {0}}}: ", FormatNames(author, true), ent.Type, Boldify(ent.Key));
            sw.WriteLine(@"{{\sc {0}}}: ", FormatNames(author, true), ent.Type, Boldify(ent.Key));

            // title
            sw.WriteLine(@"\newblock {{{0}}}.", ent.Get("title", Error("title")));

            // book issue data
            sw.WriteLine(@"\newblock {{{0}{1}{2}{3}{4}{5}{6}.}}",
                Italicize(ent.Get("booktitle", Error("booktitle"))),
                FormatIfNotEmpty(", tom {0}", ent.Get("volume", ""/*Error("volume")*/)),
                FormatIfNotEmpty(", nr {0}", ent.Get("number", ""/*Error("number")*/)),
                FormatIfNotEmpty(", {0}", ent.Get("publisher", ""/*Error("publisher")*/)),
                FormatIfNotEmpty(", {0}", ent.Get("address", ""/*Error("address")*/)),
                FormatIfNotEmpty(", {0}", ent.Get("year", ""/*Error("year")*/)),
                FormatIfNotEmpty(", str. {0}", ent.Get("pages", ""/*Error("pages")*/))
                );
        }
示例#10
0
        private void Book(StreamWriter sw, Entry ent)
        {
            string author = ent.Get("author", null);
            if (string.IsNullOrEmpty(author))
                author = ent.Get("editor", null);
            if (string.IsNullOrEmpty(author))
                author = "???????? (author unknown) ????????";

            // authors
            sw.WriteLine(@"{{\sc {0}}}: ", FormatNames(author, true));

            // title
            sw.WriteLine(@"\newblock {{{0}}}.", Italicize(ent.Get("title", Error("title"))));

            // volume and number
            if (ent.Get("series", null) != null)
                sw.WriteLine(@"\newblock {{{0} {1}}}.", ent.Get("series", ""), ent.Get("volume", Error("volume")));

            // adress of publcation and the publisher
            sw.WriteLine(GenerateBlock(ent.Get("publisher", ""), ent.Get("address", ""), ent.Get("year", "")));
        }
示例#11
0
        private void Article(StreamWriter sw, Entry ent)
        {
            string author = ent.Get("author", null);
            if (string.IsNullOrEmpty(author))
                author = "??????????????????????";

            // authors and title
            sw.WriteLine(@"\newblock {{{0}: {1}}}.", SmallCaps(FormatNames(author, true)), ent.Get("title", Error("title")));

            // journal data
            sw.WriteLine(@"\newblock {{{0} {1}{2}{3}{4}.}}",
                Italicize(ent.Get("journal", Error("journal"))), ent.Get("year", Error("year")),
                FormatIfNotEmpty(", tom {0}", ent.Get("volume", Error("volume"))),
                FormatIfNotEmpty(", nr {0}", ent.Get("number", ""/*Error("number")*/)),
                FormatIfNotEmpty(", str. {0}", ent.Get("pages", Error("pages")))
                );
        }