コード例 #1
0
        public static AttributeKeyword findAttributeKeyword(CharacterAttributeType attrType)
        {
            foreach (Keyword kwd in KEYWORDS.Values)
            {
                if (kwd is AttributeKeyword)
                {
                    AttributeKeyword attrKwd = (AttributeKeyword)kwd;
                    if (attrKwd.getAttributeType() == attrType)
                    {
                        return(attrKwd);
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        private void translateKeyword(String keyword, int param, bool hasParam)
        {
            if (Keyword.KEYWORDS.ContainsKey(keyword))
            {
                Keyword kwd = Keyword.KEYWORDS[keyword];
                switch (kwd.getKeywordType())
                {
                case KeywordType.Character:
                    parseChar(((CharacterKeyword)kwd).getOutputChar());
                    break;

                case KeywordType.Destination:
                    _parserState.rds = ((DestinationKeyword)kwd).getDestinationState();
                    if (_parserState.rds == DestinationState.Header)
                    {
                        _headerGroupBuffer = new StringBuilder(keyword);
                    }
                    break;

                case KeywordType.Attribute:
                    AttributeKeyword attrKwd = (AttributeKeyword)kwd;

                    if (hasParam)
                    {
                        _parserState.CharacterAttributes.set(attrKwd.getAttributeType(), param);
                    }
                    else
                    {
                        _parserState.CharacterAttributes.set(attrKwd.getAttributeType(), attrKwd.getDefaultValue());
                    }

                    AttributeValue val = new AttributeValue(attrKwd.getKeyword(), hasParam, param);
                    if (_handler != null)
                    {
                        List <AttributeValue> values = new List <AttributeValue>();
                        values.Add(val);
                        _handler.onCharacterAttributeChange(values);
                    }
                    break;

                case KeywordType.Special:
                    char[] output = ((SpecialKeyword)kwd).process(param, this);
                    foreach (char ch in output)
                    {
                        parseChar(ch);
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (_parserState.rds == DestinationState.Header)
                {
                    _headerGroupBuffer.Append("\\").Append(keyword);
                    if (hasParam)
                    {
                        _headerGroupBuffer.Append(param);
                    }
                }
                else
                {
                    if (_handler != null)
                    {
                        _handler.onKeyword(keyword, hasParam, param);
                    }
                }
            }
        }