Package org.eclipse.wst.sse.core.internal.encoding

Examples of org.eclipse.wst.sse.core.internal.encoding.EncodingMemento


  /**
   * Note: once this instance is created, trace info still needs to be
   * appended by caller, depending on the context its created.
   */
  private void createEncodingMemento(String detectedCharsetName) {
    fEncodingMemento = new EncodingMemento();
    fEncodingMemento.setJavaCharsetName(getAppropriateJavaCharset(detectedCharsetName));
    fEncodingMemento.setDetectedCharsetName(detectedCharsetName);
    // TODO: if detectedCharset and spec default is
    // null, need to use "work
    // bench based" defaults.
View Full Code Here


   */
  abstract public String getSpecDefaultEncoding();

  public EncodingMemento getSpecDefaultEncodingMemento() {
    resetAll();
    EncodingMemento result = null;
    String enc = getSpecDefaultEncoding();
    if (enc != null) {
      createEncodingMemento(enc, EncodingMemento.DEFAULTS_ASSUMED_FOR_EMPTY_INPUT);
      fEncodingMemento.setAppropriateDefault(enc);
      result = fEncodingMemento;
View Full Code Here

    String encodingName;
    encodingName = getSpecDefaultEncoding();
    if (encodingName != null) {
      //createEncodingMemento(encodingName,
      // EncodingMemento.USED_CONTENT_TYPE_DEFAULT);
      fEncodingMemento = new EncodingMemento();
      fEncodingMemento.setJavaCharsetName(encodingName);
      fEncodingMemento.setAppropriateDefault(encodingName);
    }
  }
View Full Code Here

   * @param detector
   * @throws IOException
   */
  private int handleCalculations(int result, IContentDescription description, IResourceCharsetDetector detector) throws IOException {
    int returnResult = result;
    EncodingMemento encodingMemento = ((XMLResourceEncodingDetector) detector).getEncodingMemento();
    if (description != null) {
      // TODO: I need to verify to see if this BOM work is always done
      // by text type.
      Object detectedByteOrderMark = encodingMemento.getUnicodeBOM();
      if (detectedByteOrderMark != null) {
        Object existingByteOrderMark = description.getProperty(IContentDescription.BYTE_ORDER_MARK);
        // not sure why would ever be different, so if is different,
        // may
        // need to "push" up into base.
        if (!detectedByteOrderMark.equals(existingByteOrderMark))
          description.setProperty(IContentDescription.BYTE_ORDER_MARK, detectedByteOrderMark);
      }


      if (!encodingMemento.isValid()) {
        // note: after setting here, its the mere presence of
        // IContentDescriptionExtended.UNSUPPORTED_CHARSET
        // in the resource's description that can be used to determine
        // if invalid in those cases, the "detected" property contains
        // an "appropriate default" to use.
        description.setProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET, encodingMemento.getInvalidEncoding());
        description.setProperty(IContentDescriptionExtended.APPROPRIATE_DEFAULT, encodingMemento.getAppropriateDefault());
      }

      Object detectedCharset = encodingMemento.getDetectedCharsetName();
      Object javaCharset = encodingMemento.getJavaCharsetName();

      // we always include detected, if its different than java
      handleDetectedSpecialCase(description, detectedCharset, javaCharset);

      if (javaCharset != null) {
View Full Code Here

    // note: if we're asked for one, we set them all. I need to be sure if
    // called
    // mulitiple times (one for each, say) that we don't waste time
    // processing same
    // content again.
    EncodingMemento encodingMemento = ((JSPResourceEncodingDetector) detector).getEncodingMemento();
    // TODO: I need to verify to see if this BOM work is always done
    // by text type.
    Object detectedByteOrderMark = encodingMemento.getUnicodeBOM();
    if (detectedByteOrderMark != null) {
      Object existingByteOrderMark = description.getProperty(IContentDescription.BYTE_ORDER_MARK);
      // not sure why would ever be different, so if is different, may
      // need to "push" up into base.
      if (!detectedByteOrderMark.equals(existingByteOrderMark))
        description.setProperty(IContentDescription.BYTE_ORDER_MARK, detectedByteOrderMark);
    }


    if (!encodingMemento.isValid()) {
      // note: after setting here, its the mere presence of
      // IContentDescriptionExtended.UNSUPPORTED_CHARSET
      // in the resource's description that can be used to determine if
      // invalid
      // in those cases, the "detected" property contains an
      // "appropriate default" to use.
      description.setProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET, encodingMemento.getInvalidEncoding());
      description.setProperty(IContentDescriptionExtended.APPROPRIATE_DEFAULT, encodingMemento.getAppropriateDefault());
    }

    Object detectedCharset = encodingMemento.getDetectedCharsetName();
    Object javaCharset = encodingMemento.getJavaCharsetName();

    // we always include detected, if its different than java
    handleDetectedSpecialCase(description, detectedCharset, javaCharset);

    if (javaCharset != null) {
View Full Code Here

  private void updateEncodingMemento() {
    boolean failed = false;
    IStructuredModel internalModel = getInternalModel();
    if (internalModel != null) {
      IStructuredDocument doc = internalModel.getStructuredDocument();
      EncodingMemento memento = doc.getEncodingMemento();
      IDocumentCharsetDetector detector = internalModel.getModelHandler().getEncodingDetector();
      if (memento != null && detector != null) {
        detector.set(doc);
        try {
          String newEncoding = detector.getEncoding();
          if (newEncoding != null) {
            memento.setDetectedCharsetName(newEncoding);
          }
        }
        catch (IOException e) {
          failed = true;
        }
View Full Code Here

    return enc;
  }

  public EncodingMemento getSpecDefaultEncodingMemento() {
    resetAll();
    EncodingMemento result = null;
    String enc = getSpecDefaultEncoding();
    if (enc != null) {
      createEncodingMemento(enc, EncodingMemento.DEFAULTS_ASSUMED_FOR_EMPTY_INPUT);
      fEncodingMemento.setAppropriateDefault(enc);
      result = fEncodingMemento;
View Full Code Here

  /**
   * Note: once this instance is created, trace info still needs to be
   * appended by caller, depending on the context its created.
   */
  private void createEncodingMemento(String detectedCharsetName) {
    fEncodingMemento = new EncodingMemento();
    fEncodingMemento.setJavaCharsetName(getAppropriateJavaCharset(detectedCharsetName));
    fEncodingMemento.setDetectedCharsetName(detectedCharsetName);
    // TODO: if detectedCharset and spec default is
    // null, need to use "work
    // bench based" defaults.
View Full Code Here

    String encodingName;
    encodingName = getSpecDefaultEncoding();
    if (encodingName != null) {
      // createEncodingMemento(encodingName,
      // EncodingMemento.USED_CONTENT_TYPE_DEFAULT);
      fEncodingMemento = new EncodingMemento();
      fEncodingMemento.setJavaCharsetName(encodingName);
      fEncodingMemento.setAppropriateDefault(encodingName);
    }
  }
View Full Code Here

    // note: if we're asked for one, we set them all. I need to be sure if
    // called
    // mulitiple times (one for each, say) that we don't waste time
    // processing same
    // content again.
    EncodingMemento encodingMemento = ((JSPResourceEncodingDetector) detector).getEncodingMemento();
    // TODO: I need to verify to see if this BOM work is always done
    // by text type.
    Object detectedByteOrderMark = encodingMemento.getUnicodeBOM();
    if (detectedByteOrderMark != null) {
      Object existingByteOrderMark = description.getProperty(IContentDescription.BYTE_ORDER_MARK);
      // not sure why would ever be different, so if is different, may
      // need to "push" up into base.
      if (!detectedByteOrderMark.equals(existingByteOrderMark))
        description.setProperty(IContentDescription.BYTE_ORDER_MARK, detectedByteOrderMark);
    }


    if (!encodingMemento.isValid()) {
      // note: after setting here, its the mere presence of
      // IContentDescriptionExtended.UNSUPPORTED_CHARSET
      // in the resource's description that can be used to determine if
      // invalid
      // in those cases, the "detected" property contains an
      // "appropriate default" to use.
      description.setProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET, encodingMemento.getInvalidEncoding());
      description.setProperty(IContentDescriptionExtended.APPROPRIATE_DEFAULT, encodingMemento.getAppropriateDefault());
    }

    Object detectedCharset = encodingMemento.getDetectedCharsetName();
    Object javaCharset = encodingMemento.getJavaCharsetName();

    // we always include detected, if its different than java
    handleDetectedSpecialCase(description, detectedCharset, javaCharset);

    if (javaCharset != null) {
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.core.internal.encoding.EncodingMemento

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.