outputproperties.java

来自「java jdk 1.4的源码」· Java 代码 · 共 1,123 行 · 第 1/3 页

JAVA
1,123
字号
              if(null == m_text_properties.getProperty(OutputKeys.ENCODING))              {                String mimeEncoding = org.apache.xalan.serialize.Encodings.getMimeEncoding(null);                m_text_properties.put(OutputKeys.ENCODING, mimeEncoding);              }            }        defaultProperties = m_text_properties;      }      else      {        // TODO: Calculate res file from name.        defaultProperties = m_xml_properties;      }    }    catch (IOException ioe)    {      throw new WrappedRuntimeException(            "Output method is "+method+" could not load "+fileName+" (check CLASSPATH)",             ioe);    }    return defaultProperties;  }  /**   * Clone this OutputProperties, including a clone of the wrapped Properties   * reference.   *   * @return A new OutputProperties reference, mutation of which should not   *         effect this object.   */  public Object clone()  {    try    {      OutputProperties cloned = (OutputProperties) super.clone();      cloned.m_properties = (Properties) cloned.m_properties.clone();      return cloned;    }    catch (CloneNotSupportedException e)    {      return null;    }  }  /**   * Set an output property.   *   * @param key the key to be placed into the property list.   * @param value the value corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */  public void setProperty(QName key, String value)  {    setProperty(key.toNamespacedString(), value);  }  /**   * Set an output property.   *   * @param key the key to be placed into the property list.   * @param value the value corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */  public void setProperty(String key, String value)  {    if(key.equals(OutputKeys.METHOD))    {      setMethodDefaults(value);    }        if (key.startsWith(S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL))      key = S_BUILTIN_EXTENSIONS_UNIVERSAL + key.substring(S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN);        m_properties.put(key, value);  }  /**   * Searches for the property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>null</code> if the property is not found.   *   * @param   key   the property key.   * @return  the value in this property list with the specified key value.   */  public String getProperty(QName key)  {    return m_properties.getProperty(key.toNamespacedString());  }  /**   * Searches for the property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>null</code> if the property is not found.   *   * @param   key   the property key.   * @return  the value in this property list with the specified key value.   */  public String getProperty(String key)  {    if (key.startsWith(S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL))      key = S_BUILTIN_EXTENSIONS_UNIVERSAL + key.substring(S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN);    return m_properties.getProperty(key);  }  /**   * Set an output property.   *   * @param key the key to be placed into the property list.   * @param value the value corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */  public void setBooleanProperty(QName key, boolean value)  {    m_properties.put(key.toNamespacedString(), value ? "yes" : "no");  }  /**   * Set an output property.   *   * @param key the key to be placed into the property list.   * @param value the value corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */  public void setBooleanProperty(String key, boolean value)  {    m_properties.put(key, value ? "yes" : "no");  }  /**   * Searches for the boolean property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>false</code> if the property is not found, or if the value is other   * than "yes".   *   * @param   key   the property key.   * @return  the value in this property list as a boolean value, or false   * if null or not "yes".   */  public boolean getBooleanProperty(QName key)  {    return getBooleanProperty(key.toNamespacedString());  }  /**   * Searches for the boolean property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>false</code> if the property is not found, or if the value is other   * than "yes".   *   * @param   key   the property key.   * @return  the value in this property list as a boolean value, or false   * if null or not "yes".   */  public boolean getBooleanProperty(String key)  {    return getBooleanProperty(key, m_properties);  }  /**   * Searches for the boolean property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>false</code> if the property is not found, or if the value is other   * than "yes".   *   * @param   key   the property key.   * @param   props   the list of properties that will be searched.   * @return  the value in this property list as a boolean value, or false   * if null or not "yes".   */  public static boolean getBooleanProperty(String key, Properties props)  {    String s = props.getProperty(key);    if (null == s ||!s.equals("yes"))      return false;    else      return true;  }    /**   * Set an output property.   *   * @param key the key to be placed into the property list.   * @param value the value corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */  public void setIntProperty(QName key, int value)  {    setIntProperty(key.toNamespacedString(), value);  }  /**   * Set an output property.   *   * @param key the key to be placed into the property list.   * @param value the value corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */  public void setIntProperty(String key, int value)  {    m_properties.put(key, Integer.toString(value));  }  /**   * Searches for the int property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>false</code> if the property is not found, or if the value is other   * than "yes".   *   * @param   key   the property key.   * @return  the value in this property list as a int value, or false   * if null or not a number.   */  public int getIntProperty(QName key)  {    return getIntProperty(key.toNamespacedString());  }  /**   * Searches for the int property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>false</code> if the property is not found, or if the value is other   * than "yes".   *   * @param   key   the property key.   * @return  the value in this property list as a int value, or false   * if null or not a number.   */  public int getIntProperty(String key)  {    return getIntProperty(key, m_properties);  }  /**   * Searches for the int property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>false</code> if the property is not found, or if the value is other   * than "yes".   *   * @param   key   the property key.   * @param   props   the list of properties that will be searched.   * @return  the value in this property list as a int value, or 0   * if null or not a number.   */  public static int getIntProperty(String key, Properties props)  {    String s = props.getProperty(key);    if (null == s)      return 0;    else      return Integer.parseInt(s);  }  /**   * Set an output property with a QName value.  The QName will be turned   * into a string with the namespace in curly brackets.   *   * @param key the key to be placed into the property list.   * @param value the value corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */  public void setQNameProperty(QName key, QName value)  {    setQNameProperty(key.toNamespacedString(), value);  }    /**   * Reset the default properties based on the method.   *   * @param method the method value.   * @see javax.xml.transform.OutputKeys   */  public void setMethodDefaults(String method)  {    String defaultMethod = m_properties.getProperty(OutputKeys.METHOD);    if((null == defaultMethod) || !defaultMethod.equals(method))    {      Properties savedProps = m_properties;      Properties newDefaults = getDefaultMethodProperties(method);      m_properties = new Properties(newDefaults);      copyFrom(savedProps, false);    }  }    /**   * Set an output property with a QName value.  The QName will be turned   * into a string with the namespace in curly brackets.   *   * @param key the key to be placed into the property list.   * @param value the value corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */  public void setQNameProperty(String key, QName value)  {    setProperty(key, value.toNamespacedString());  }  /**   * Searches for the qname property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>null</code> if the property is not found.   *   * @param   key   the property key.   * @return  the value in this property list as a QName value, or false   * if null or not "yes".   */  public QName getQNameProperty(QName key)  {    return getQNameProperty(key.toNamespacedString());  }  /**   * Searches for the qname property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>null</code> if the property is not found.   *   * @param   key   the property key.   * @return  the value in this property list as a QName value, or false   * if null or not "yes".   */  public QName getQNameProperty(String key)  {    return getQNameProperty(key, m_properties);  }  /**   * Searches for the qname property with the specified key in the property list.   * If the key is not found in this property list, the default property list,   * and its defaults, recursively, are then checked. The method returns   * <code>null</code> if the property is not found.   *   * @param   key   the property key.   * @param props the list of properties to search in.   * @return  the value in this property list as a QName value, or false   * if null or not "yes".   */  public static QName getQNameProperty(String key, Properties props)  {    String s = props.getProperty(key);    if (null != s)      return QName.getQNameFromString(s);    else      return null;  }  /**   * Set an output property with a QName list value.  The QNames will be turned   * into strings with the namespace in curly brackets.   *   * @param key the key to be placed into the property list.   * @param v non-null list of QNames corresponding to <tt>key</tt>.   * @see javax.xml.transform.OutputKeys   */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?