jaxp/src/share/classes/com/sun/org/apache/xpath/internal/functions/FuncGenerateId.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 6 7f561c08de6b
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * Copyright 1999-2004 The Apache Software Foundation.
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * Licensed under the Apache License, Version 2.0 (the "License");
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * you may not use this file except in compliance with the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 * You may obtain a copy of the License at
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *     http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
 * $Id: FuncGenerateId.java,v 1.2.4.1 2005/09/14 20:18:45 jeffsuttor Exp $
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
package com.sun.org.apache.xpath.internal.functions;
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.xml.internal.dtm.DTM;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import com.sun.org.apache.xpath.internal.XPathContext;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import com.sun.org.apache.xpath.internal.objects.XObject;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import com.sun.org.apache.xpath.internal.objects.XString;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
 * Execute the GenerateId() function.
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
 * @xsl.usage advanced
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
public class FuncGenerateId extends FunctionDef1Arg
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
    static final long serialVersionUID = 973544842091724273L;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
  /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
   * Execute the function.  The function must return
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
   * a valid object.
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
   * @param xctxt The current execution context.
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
   * @return A valid XObject.
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
   *
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
   * @throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
   */
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
  public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
  {
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
    int which = getArg0AsNode(xctxt);
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
    if (DTM.NULL != which)
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
      // Note that this is a different value than in previous releases
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
      // of Xalan. It's sensitive to the exact encoding of the node
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
      // handle anyway, so fighting to maintain backward compatability
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
      // really didn't make sense; it may change again as we continue
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
      // to experiment with balancing document and node numbers within
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
      // that value.
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
      return new XString("N" + Integer.toHexString(which).toUpperCase());
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
    else
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
      return XString.EMPTYSTRING;
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
  }
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
}