< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Lexer.java

Print this page


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Oct 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xpath.internal.compiler;
  23 


 453     {
 454       m_processor.m_token = null;
 455       m_processor.m_tokenChar = 0;
 456     }
 457   }
 458 
 459   /**
 460    * Given a string, return the corresponding keyword token.
 461    *
 462    * @param key The keyword.
 463    *
 464    * @return An opcode value.
 465    */
 466   final int getKeywordToken(String key)
 467   {
 468 
 469     int tok;
 470 
 471     try
 472     {
 473       Integer itok = (Integer) Keywords.getKeyWord(key);
 474 
 475       tok = (null != itok) ? itok.intValue() : 0;
 476     }
 477     catch (NullPointerException npe)
 478     {
 479       tok = 0;
 480     }
 481     catch (ClassCastException cce)
 482     {
 483       tok = 0;
 484     }
 485 
 486     return tok;
 487   }
 488 
 489   /**
 490    * Record the current token in the passed vector.
 491    *
 492    * @param targetStrings a list of strings.
 493    */


 570    */
 571   private int mapNSTokens(String pat, int startSubstring, int posOfNSSep,
 572                           int posOfScan)
 573            throws javax.xml.transform.TransformerException
 574  {
 575 
 576     String prefix = "";
 577 
 578     if ((startSubstring >= 0) && (posOfNSSep >= 0))
 579     {
 580        prefix = pat.substring(startSubstring, posOfNSSep);
 581     }
 582     String uName;
 583 
 584     if ((null != m_namespaceContext) &&!prefix.equals("*")
 585             &&!prefix.equals("xmlns"))
 586     {
 587       try
 588       {
 589         if (prefix.length() > 0)
 590           uName = ((PrefixResolver) m_namespaceContext).getNamespaceForPrefix(
 591             prefix);
 592         else
 593         {
 594 
 595           // Assume last was wildcard. This is not legal according
 596           // to the draft. Set the below to true to make namespace
 597           // wildcards work.
 598           if (false)
 599           {
 600             addToTokenQueue(":");
 601 
 602             String s = pat.substring(posOfNSSep + 1, posOfScan);
 603 
 604             if (s.length() > 0)
 605               addToTokenQueue(s);
 606 
 607             return -1;
 608           }
 609           else
 610           {
 611             uName =
 612               ((PrefixResolver) m_namespaceContext).getNamespaceForPrefix(
 613                 prefix);
 614           }
 615         }
 616       }
 617       catch (ClassCastException cce)
 618       {
 619         uName = m_namespaceContext.getNamespaceForPrefix(prefix);
 620       }
 621     }
 622     else
 623     {
 624       uName = prefix;
 625     }
 626 
 627     if ((null != uName) && (uName.length() > 0))
 628     {
 629       addToTokenQueue(uName);
 630       addToTokenQueue(":");
 631 
 632       String s = pat.substring(posOfNSSep + 1, posOfScan);
 633 
   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xpath.internal.compiler;
  23 


 453     {
 454       m_processor.m_token = null;
 455       m_processor.m_tokenChar = 0;
 456     }
 457   }
 458 
 459   /**
 460    * Given a string, return the corresponding keyword token.
 461    *
 462    * @param key The keyword.
 463    *
 464    * @return An opcode value.
 465    */
 466   final int getKeywordToken(String key)
 467   {
 468 
 469     int tok;
 470 
 471     try
 472     {
 473       Integer itok = Keywords.getKeyWord(key);
 474 
 475       tok = (null != itok) ? itok.intValue() : 0;
 476     }
 477     catch (NullPointerException npe)
 478     {
 479       tok = 0;
 480     }
 481     catch (ClassCastException cce)
 482     {
 483       tok = 0;
 484     }
 485 
 486     return tok;
 487   }
 488 
 489   /**
 490    * Record the current token in the passed vector.
 491    *
 492    * @param targetStrings a list of strings.
 493    */


 570    */
 571   private int mapNSTokens(String pat, int startSubstring, int posOfNSSep,
 572                           int posOfScan)
 573            throws javax.xml.transform.TransformerException
 574  {
 575 
 576     String prefix = "";
 577 
 578     if ((startSubstring >= 0) && (posOfNSSep >= 0))
 579     {
 580        prefix = pat.substring(startSubstring, posOfNSSep);
 581     }
 582     String uName;
 583 
 584     if ((null != m_namespaceContext) &&!prefix.equals("*")
 585             &&!prefix.equals("xmlns"))
 586     {
 587       try
 588       {
 589         if (prefix.length() > 0)
 590           uName = m_namespaceContext.getNamespaceForPrefix(prefix);

 591         else
 592         {
 593 
 594           // Assume last was wildcard. This is not legal according
 595           // to the draft. Set the below to true to make namespace
 596           // wildcards work.
 597           if (false)
 598           {
 599             addToTokenQueue(":");
 600 
 601             String s = pat.substring(posOfNSSep + 1, posOfScan);
 602 
 603             if (s.length() > 0)
 604               addToTokenQueue(s);
 605 
 606             return -1;
 607           }
 608           else
 609           {
 610             uName = m_namespaceContext.getNamespaceForPrefix(prefix);


 611           }
 612         }
 613       }
 614       catch (ClassCastException cce)
 615       {
 616         uName = m_namespaceContext.getNamespaceForPrefix(prefix);
 617       }
 618     }
 619     else
 620     {
 621       uName = prefix;
 622     }
 623 
 624     if ((null != uName) && (uName.length() > 0))
 625     {
 626       addToTokenQueue(uName);
 627       addToTokenQueue(":");
 628 
 629       String s = pat.substring(posOfNSSep + 1, posOfScan);
 630 
< prev index next >