本文整理汇总了C#中System.util.StringTokenizer.HasMoreTokens方法的典型用法代码示例。如果您正苦于以下问题:C# StringTokenizer.HasMoreTokens方法的具体用法?C# StringTokenizer.HasMoreTokens怎么用?C# StringTokenizer.HasMoreTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.util.StringTokenizer
的用法示例。
在下文中一共展示了StringTokenizer.HasMoreTokens方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetField
internal bool SetField(String field, PdfObject value) {
Hashtable map = fields;
StringTokenizer tk = new StringTokenizer(field, ".");
if (!tk.HasMoreTokens())
return false;
while (true) {
String s = tk.NextToken();
Object obj = map[s];
if (tk.HasMoreTokens()) {
if (obj == null) {
obj = new Hashtable();
map[s] = obj;
map = (Hashtable)obj;
continue;
}
else if (obj is Hashtable)
map = (Hashtable)obj;
else
return false;
}
else {
if (!(obj is Hashtable)) {
map[s] = value;
return true;
}
else
return false;
}
}
}
示例2: GlyphList
static GlyphList()
{
Stream istr = null;
try {
istr = BaseFont.GetResourceStream("glyphlist.txt");
if (istr == null) {
string msg = string.Format("glyphlist.txt not found as resource. (path: {0})", BaseFont.RESOURCE_PATH);
throw new Exception(msg);
}
byte[] buf = new byte[1024];
MemoryStream outp = new MemoryStream();
while (true) {
int size = istr.Read(buf, 0, buf.Length);
if (size == 0)
break;
outp.Write(buf, 0, size);
}
istr.Close();
istr = null;
String s = PdfEncodings.ConvertToString(outp.ToArray(), null);
StringTokenizer tk = new StringTokenizer(s, "\r\n");
while (tk.HasMoreTokens()) {
String line = tk.NextToken();
if (line.StartsWith("#"))
continue;
StringTokenizer t2 = new StringTokenizer(line, " ;\r\n\t\f");
String name = null;
String hex = null;
if (!t2.HasMoreTokens())
continue;
name = t2.NextToken();
if (!t2.HasMoreTokens())
continue;
hex = t2.NextToken();
int num = int.Parse(hex, NumberStyles.HexNumber);
unicode2names[num] = name;
names2unicode[name] = new int[]{num};
}
}
catch (Exception e) {
Console.Error.WriteLine("glyphlist.txt loading error: " + e.Message);
}
finally {
if (istr != null) {
try {
istr.Close();
}
catch {
// empty on purpose
}
}
}
}
示例3: CJKFont
/** Creates a CJK font.
* @param fontName the name of the font
* @param enc the encoding of the font
* @param emb always <CODE>false</CODE>. CJK font and not embedded
* @throws DocumentException on error
* @throws IOException on error
*/
internal CJKFont(string fontName, string enc, bool emb)
{
LoadProperties();
this.FontType = FONT_TYPE_CJK;
string nameBase = GetBaseName(fontName);
if (!IsCJKFont(nameBase, enc))
throw new DocumentException(MessageLocalization.GetComposedMessage("font.1.with.2.encoding.is.not.a.cjk.font", fontName, enc));
if (nameBase.Length < fontName.Length) {
style = fontName.Substring(nameBase.Length);
fontName = nameBase;
}
this.fontName = fontName;
encoding = CJK_ENCODING;
vertical = enc.EndsWith("V");
CMap = enc;
if (enc.StartsWith("Identity-")) {
cidDirect = true;
string s = cjkFonts[fontName];
s = s.Substring(0, s.IndexOf('_'));
char[] c;
lock (allCMaps) {
allCMaps.TryGetValue(s, out c);
}
if (c == null) {
c = ReadCMap(s);
if (c == null)
throw new DocumentException(MessageLocalization.GetComposedMessage("the.cmap.1.does.not.exist.as.a.resource", s));
c[CID_NEWLINE] = '\n';
lock (allCMaps) {
allCMaps[s] = c;
}
}
translationMap = c;
}
else {
char[] c;
lock (allCMaps) {
allCMaps.TryGetValue(enc, out c);
}
if (c == null) {
string s = cjkEncodings[enc];
if (s == null)
throw new DocumentException(MessageLocalization.GetComposedMessage("the.resource.cjkencodings.properties.does.not.contain.the.encoding.1", enc));
StringTokenizer tk = new StringTokenizer(s);
string nt = tk.NextToken();
lock (allCMaps) {
allCMaps.TryGetValue(nt, out c);
}
if (c == null) {
c = ReadCMap(nt);
lock (allCMaps) {
allCMaps[nt] = c;
}
}
if (tk.HasMoreTokens()) {
string nt2 = tk.NextToken();
char[] m2 = ReadCMap(nt2);
for (int k = 0; k < 0x10000; ++k) {
if (m2[k] == 0)
m2[k] = c[k];
}
lock (allCMaps) {
allCMaps[enc] = m2;
}
c = m2;
}
}
translationMap = c;
}
lock (allFonts) {
allFonts.TryGetValue(fontName, out fontDesc);
}
allFonts.TryGetValue(fontName, out fontDesc);
if (fontDesc == null) {
fontDesc = ReadFontProperties(fontName);
lock (allFonts) {
allFonts[fontName] = fontDesc;
}
}
hMetrics = (IntHashtable)fontDesc["W"];
vMetrics = (IntHashtable)fontDesc["W2"];
}
示例4: GetFont
public Font GetFont(ChainedProperties props) {
String face = props[ElementTags.FACE];
if (face != null) {
StringTokenizer tok = new StringTokenizer(face, ",");
while (tok.HasMoreTokens()) {
face = tok.NextToken().Trim();
if (face.StartsWith("\""))
face = face.Substring(1);
if (face.EndsWith("\""))
face = face.Substring(0, face.Length - 1);
if (fontImp.IsRegistered(face))
break;
}
}
int style = 0;
if (props.HasProperty(HtmlTags.I))
style |= Font.ITALIC;
if (props.HasProperty(HtmlTags.B))
style |= Font.BOLD;
if (props.HasProperty(HtmlTags.U))
style |= Font.UNDERLINE;
if (props.HasProperty(HtmlTags.S))
style |= Font.STRIKETHRU ;
String value = props[ElementTags.SIZE];
float size = 12;
if (value != null)
size = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
BaseColor color = Markup.DecodeColor(props["color"]);
String encoding = props["encoding"];
if (encoding == null)
encoding = BaseFont.WINANSI;
return fontImp.GetFont(face, encoding, true, size, style, color);
}
示例5: ParseAttributes
/// <summary>
/// This method parses a string with attributes and returns a Properties object.
/// </summary>
/// <param name="str">a string of this form: 'key1="value1"; key2="value2";... keyN="valueN" '</param>
/// <returns>a Properties object</returns>
public static Properties ParseAttributes(string str) {
Properties result = new Properties();
if (str == null) return result;
StringTokenizer keyValuePairs = new StringTokenizer(str, ";");
StringTokenizer keyValuePair;
string key;
string value;
while (keyValuePairs.HasMoreTokens()) {
keyValuePair = new StringTokenizer(keyValuePairs.NextToken(), ":");
if (keyValuePair.HasMoreTokens()) key = keyValuePair.NextToken().Trim().Trim();
else continue;
if (keyValuePair.HasMoreTokens()) value = keyValuePair.NextToken().Trim();
else continue;
if (value.StartsWith("\"")) value = value.Substring(1);
if (value.EndsWith("\"")) value = value.Substring(0, value.Length - 1);
result.Add(key.ToLower(CultureInfo.InvariantCulture), value);
}
return result;
}
示例6: SetParagraphLeading
/**
* Sets the leading of a Paragraph object.
* @param paragraph the Paragraph for which we set the leading
* @param leading the String value of the leading
*/
protected static void SetParagraphLeading(Paragraph paragraph, String leading) {
// default leading
if (leading == null) {
paragraph.SetLeading(0, 1.5f);
return;
}
try {
StringTokenizer tk = new StringTokenizer(leading, " ,");
// absolute leading
String v = tk.NextToken();
float v1 = float.Parse(v, CultureInfo.InvariantCulture);
if (!tk.HasMoreTokens()) {
paragraph.SetLeading(v1, 0);
return;
}
// relative leading
v = tk.NextToken();
float v2 = float.Parse(v, CultureInfo.InvariantCulture);
paragraph.SetLeading(v1, v2);
} catch {
// default leading
paragraph.SetLeading(0, 1.5f);
}
}
示例7: MergeField
internal void MergeField(String name, AcroFields.Item item)
{
Hashtable map = fieldTree;
StringTokenizer tk = new StringTokenizer(name, ".");
if (!tk.HasMoreTokens())
return;
while (true) {
String s = tk.NextToken();
Object obj = map[s];
if (tk.HasMoreTokens()) {
if (obj == null) {
obj = new Hashtable();
map[s] = obj;
map = (Hashtable)obj;
continue;
}
else if (obj is Hashtable)
map = (Hashtable)obj;
else
return;
}
else {
if (obj is Hashtable)
return;
PdfDictionary merged = (PdfDictionary)item.merged[0];
if (obj == null) {
PdfDictionary field = new PdfDictionary();
foreach (PdfName key in merged.Keys) {
if (fieldKeys.ContainsKey(key))
field.Put(key, merged.Get(key));
}
ArrayList list = new ArrayList();
list.Add(field);
CreateWidgets(list, item);
map[s] = list;
}
else {
ArrayList list = (ArrayList)obj;
PdfDictionary field = (PdfDictionary)list[0];
PdfName type1 = (PdfName)field.Get(PdfName.FT);
PdfName type2 = (PdfName)merged.Get(PdfName.FT);
if (type1 == null || !type1.Equals(type2))
return;
int flag1 = 0;
PdfObject f1 = field.Get(PdfName.FF);
if (f1 != null && f1.IsNumber())
flag1 = ((PdfNumber)f1).IntValue;
int flag2 = 0;
PdfObject f2 = merged.Get(PdfName.FF);
if (f2 != null && f2.IsNumber())
flag2 = ((PdfNumber)f2).IntValue;
if (type1.Equals(PdfName.BTN)) {
if (((flag1 ^ flag2) & PdfFormField.FF_PUSHBUTTON) != 0)
return;
if ((flag1 & PdfFormField.FF_PUSHBUTTON) == 0 && ((flag1 ^ flag2) & PdfFormField.FF_RADIO) != 0)
return;
}
else if (type1.Equals(PdfName.CH)) {
if (((flag1 ^ flag2) & PdfFormField.FF_COMBO) != 0)
return;
}
CreateWidgets(list, item);
}
return;
}
}
}
示例8: HTMLWorker
static HTMLWorker() {
StringTokenizer tok = new StringTokenizer(tagsSupportedString);
while (tok.HasMoreTokens())
tagsSupported[tok.NextToken()] = null;
}
示例9: CJKFont
/** Creates a CJK font.
* @param fontName the name of the font
* @param enc the encoding of the font
* @param emb always <CODE>false</CODE>. CJK font and not embedded
* @throws DocumentException on error
* @throws IOException on error
*/
internal CJKFont(string fontName, string enc, bool emb)
{
LoadProperties();
this.FontType = FONT_TYPE_CJK;
string nameBase = GetBaseName(fontName);
if (!IsCJKFont(nameBase, enc))
throw new DocumentException("Font '" + fontName + "' with '" + enc + "' encoding is not a CJK font.");
if (nameBase.Length < fontName.Length) {
style = fontName.Substring(nameBase.Length);
fontName = nameBase;
}
this.fontName = fontName;
encoding = CJK_ENCODING;
vertical = enc.EndsWith("V");
CMap = enc;
if (enc.StartsWith("Identity-")) {
cidDirect = true;
string s = cjkFonts[fontName];
s = s.Substring(0, s.IndexOf('_'));
char[] c = (char[])allCMaps[s];
if (c == null) {
c = ReadCMap(s);
if (c == null)
throw new DocumentException("The cmap " + s + " does not exist as a resource.");
c[CID_NEWLINE] = '\n';
allCMaps.Add(s, c);
}
translationMap = c;
}
else {
char[] c = (char[])allCMaps[enc];
if (c == null) {
string s = cjkEncodings[enc];
if (s == null)
throw new DocumentException("The resource cjkencodings.properties does not contain the encoding " + enc);
StringTokenizer tk = new StringTokenizer(s);
string nt = tk.NextToken();
c = (char[])allCMaps[nt];
if (c == null) {
c = ReadCMap(nt);
allCMaps.Add(nt, c);
}
if (tk.HasMoreTokens()) {
string nt2 = tk.NextToken();
char[] m2 = ReadCMap(nt2);
for (int k = 0; k < 0x10000; ++k) {
if (m2[k] == 0)
m2[k] = c[k];
}
allCMaps.Add(enc, m2);
c = m2;
}
}
translationMap = c;
}
fontDesc = (Hashtable)allFonts[fontName];
if (fontDesc == null) {
fontDesc = ReadFontProperties(fontName);
allFonts.Add(fontName, fontDesc);
}
hMetrics = (IntHashtable)fontDesc["W"];
vMetrics = (IntHashtable)fontDesc["W2"];
}
示例10: GetTable
/**
* Creates an Table object based on a list of properties.
* @param attributes
* @return a Table
*/
public static Table GetTable(Properties attributes)
{
String value;
Table table;
value = attributes[ElementTags.WIDTHS];
if (value != null) {
StringTokenizer widthTokens = new StringTokenizer(value, ";");
ArrayList values = new ArrayList();
while (widthTokens.HasMoreTokens()) {
values.Add(widthTokens.NextToken());
}
table = new Table(values.Count);
float[] widths = new float[table.Columns];
for (int i = 0; i < values.Count; i++) {
value = (String)values[i];
widths[i] = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
}
table.Widths = widths;
}
else {
value = attributes[ElementTags.COLUMNS];
try {
table = new Table(int.Parse(value));
}
catch {
table = new Table(1);
}
}
table.Border = Table.BOX;
table.BorderWidth = 1;
table.DefaultCell.Border = Table.BOX;
value = attributes[ElementTags.LASTHEADERROW];
if (value != null) {
table.LastHeaderRow = int.Parse(value);
}
value = attributes[ElementTags.ALIGN];
if (value != null) {
table.SetAlignment(value);
}
value = attributes[ElementTags.CELLSPACING];
if (value != null) {
table.Spacing = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
}
value = attributes[ElementTags.CELLPADDING];
if (value != null) {
table.Padding = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
}
value = attributes[ElementTags.OFFSET];
if (value != null) {
table.Offset = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
}
value = attributes[ElementTags.WIDTH];
if (value != null) {
if (value.EndsWith("%"))
table.Width = float.Parse(value.Substring(0, value.Length - 1), System.Globalization.NumberFormatInfo.InvariantInfo);
else {
table.Width = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
table.Locked = true;
}
}
table.TableFitsPage = Utilities.CheckTrueOrFalse(attributes, ElementTags.TABLEFITSPAGE);
table.CellsFitPage = Utilities.CheckTrueOrFalse(attributes, ElementTags.CELLSFITPAGE);
table.Convert2pdfptable = Utilities.CheckTrueOrFalse(attributes, ElementTags.CONVERT2PDFP);
SetRectangleProperties(table, attributes);
return table;
}
示例11: GetField
/** Gets the field value.
* @param field the field name
* @return the field value or <CODE>null</CODE> if not found
*/
public String GetField(String field)
{
Hashtable map = fields;
StringTokenizer tk = new StringTokenizer(field, ".");
if (!tk.HasMoreTokens())
return null;
while (true) {
String s = tk.NextToken();
Object obj = map[s];
if (obj == null)
return null;
if (tk.HasMoreTokens()) {
if (obj is Hashtable)
map = (Hashtable)obj;
else
return null;
}
else {
if (obj is Hashtable)
return null;
else {
if (((PdfObject)obj).IsString())
return ((PdfString)obj).ToUnicodeString();
else
return PdfName.DecodeName(obj.ToString());
}
}
}
}
示例12: Text
virtual public void Text(String str) {
StringTokenizer tk = new StringTokenizer(str);
while (tk.HasMoreTokens()) {
String word = tk.NextToken();
// System.out.Println("\"" + word + "\"");
switch (currElement) {
case ELEM_CLASSES:
consumer.AddClass(word);
break;
case ELEM_EXCEPTIONS:
exception.Add(word);
exception = NormalizeException(exception);
consumer.AddException(GetExceptionWord(exception), new List<object>(exception));
exception.Clear();
break;
case ELEM_PATTERNS:
consumer.AddPattern(GetPattern(word),
GetInterletterValues(word));
break;
}
}
}
示例13: CreateDestinationArray
internal static PdfArray CreateDestinationArray(String value, PdfWriter writer)
{
PdfArray ar = new PdfArray();
StringTokenizer tk = new StringTokenizer(value);
int n = int.Parse(tk.NextToken());
ar.Add(writer.GetPageReference(n));
if (!tk.HasMoreTokens()) {
ar.Add(PdfName.XYZ);
ar.Add(new float[]{0, 10000, 0});
}
else {
String fn = tk.NextToken();
if (fn.StartsWith("/"))
fn = fn.Substring(1);
ar.Add(new PdfName(fn));
for (int k = 0; k < 4 && tk.HasMoreTokens(); ++k) {
fn = tk.NextToken();
if (fn.Equals("null"))
ar.Add(PdfNull.PDFNULL);
else
ar.Add(new PdfNumber(fn));
}
}
return ar;
}
示例14: CreateOutlineAction
internal static void CreateOutlineAction(PdfDictionary outline, Dictionary<String, Object> map, PdfWriter writer, bool namedAsNames) {
try {
String action = GetVal(map, "Action");
if ("GoTo".Equals(action)) {
String p;
if ((p = GetVal(map, "Named")) != null) {
if (namedAsNames)
outline.Put(PdfName.DEST, new PdfName(p));
else
outline.Put(PdfName.DEST, new PdfString(p, null));
}
else if ((p = GetVal(map, "Page")) != null) {
PdfArray ar = new PdfArray();
StringTokenizer tk = new StringTokenizer(p);
int n = int.Parse(tk.NextToken());
ar.Add(writer.GetPageReference(n));
if (!tk.HasMoreTokens()) {
ar.Add(PdfName.XYZ);
ar.Add(new float[]{0, 10000, 0});
}
else {
String fn = tk.NextToken();
if (fn.StartsWith("/"))
fn = fn.Substring(1);
ar.Add(new PdfName(fn));
for (int k = 0; k < 4 && tk.HasMoreTokens(); ++k) {
fn = tk.NextToken();
if (fn.Equals("null"))
ar.Add(PdfNull.PDFNULL);
else
ar.Add(new PdfNumber(fn));
}
}
outline.Put(PdfName.DEST, ar);
}
}
else if ("GoToR".Equals(action)) {
String p;
PdfDictionary dic = new PdfDictionary();
if ((p = GetVal(map, "Named")) != null)
dic.Put(PdfName.D, new PdfString(p, null));
else if ((p = GetVal(map, "NamedN")) != null)
dic.Put(PdfName.D, new PdfName(p));
else if ((p = GetVal(map, "Page")) != null){
PdfArray ar = new PdfArray();
StringTokenizer tk = new StringTokenizer(p);
ar.Add(new PdfNumber(tk.NextToken()));
if (!tk.HasMoreTokens()) {
ar.Add(PdfName.XYZ);
ar.Add(new float[]{0, 10000, 0});
}
else {
String fn = tk.NextToken();
if (fn.StartsWith("/"))
fn = fn.Substring(1);
ar.Add(new PdfName(fn));
for (int k = 0; k < 4 && tk.HasMoreTokens(); ++k) {
fn = tk.NextToken();
if (fn.Equals("null"))
ar.Add(PdfNull.PDFNULL);
else
ar.Add(new PdfNumber(fn));
}
}
dic.Put(PdfName.D, ar);
}
String file = GetVal(map, "File");
if (dic.Size > 0 && file != null) {
dic.Put(PdfName.S, PdfName.GOTOR);
dic.Put(PdfName.F, new PdfString(file));
String nw = GetVal(map, "NewWindow");
if (nw != null) {
if (nw.Equals("true"))
dic.Put(PdfName.NEWWINDOW, PdfBoolean.PDFTRUE);
else if (nw.Equals("false"))
dic.Put(PdfName.NEWWINDOW, PdfBoolean.PDFFALSE);
}
outline.Put(PdfName.A, dic);
}
}
else if ("URI".Equals(action)) {
String uri = GetVal(map, "URI");
if (uri != null) {
PdfDictionary dic = new PdfDictionary();
dic.Put(PdfName.S, PdfName.URI);
dic.Put(PdfName.URI, new PdfString(uri));
outline.Put(PdfName.A, dic);
}
}
else if ("JS".Equals(action)) {
String code = GetVal(map, "Code");
if(code != null) {
outline.Put(PdfName.A, PdfAction.JavaScript(code, writer));
}
}
else if ("Launch".Equals(action)) {
String file = GetVal(map, "File");
if (file != null) {
PdfDictionary dic = new PdfDictionary();
dic.Put(PdfName.S, PdfName.LAUNCH);
//.........这里部分代码省略.........
示例15: DrawMultiLineOfText
virtual public void DrawMultiLineOfText(PdfFormField field, string text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) {
PdfAppearance tp = PdfAppearance.CreateAppearance(writer, urx - llx, ury - lly);
PdfAppearance tp2 = (PdfAppearance)tp.Duplicate;
tp2.SetFontAndSize(font, fontSize);
tp2.ResetRGBColorFill();
field.DefaultAppearanceString = tp2;
tp.DrawTextField(0f, 0f, urx - llx, ury - lly);
tp.BeginVariableText();
tp.SaveState();
tp.Rectangle(3f, 3f, urx - llx - 6f, ury - lly - 6f);
tp.Clip();
tp.NewPath();
tp.BeginText();
tp.SetFontAndSize(font, fontSize);
tp.ResetRGBColorFill();
tp.SetTextMatrix(4, 5);
System.util.StringTokenizer tokenizer = new System.util.StringTokenizer(text, "\n");
float yPos = ury - lly;
while (tokenizer.HasMoreTokens()) {
yPos -= fontSize * 1.2f;
tp.ShowTextAligned(PdfContentByte.ALIGN_LEFT, tokenizer.NextToken(), 3, yPos, 0);
}
tp.EndText();
tp.RestoreState();
tp.EndVariableText();
field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
}