gpt4 book ai didi

org.apache.knox.gateway.util.XmlUtils.createDocument()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 06:46:40 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.knox.gateway.util.XmlUtils.createDocument()方法的一些代码示例,展示了XmlUtils.createDocument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlUtils.createDocument()方法的具体详情如下:
包路径:org.apache.knox.gateway.util.XmlUtils
类名称:XmlUtils
方法名:createDocument

XmlUtils.createDocument介绍

暂无

代码示例

代码示例来源:origin: org.apache.knox/gateway-util-common

public static Document createDocument() throws ParserConfigurationException {
 return createDocument(true);
}

代码示例来源:origin: apache/knox

public static Document createDocument() throws ParserConfigurationException {
 return createDocument(true);
}

代码示例来源:origin: org.apache.knox/gateway-provider-rewrite

protected HtmlFilterReaderBase( Reader reader ) throws IOException, ParserConfigurationException {
 this.reader = reader;
 document = XmlUtils.createDocument( false );
 stack = new Stack<>();
 parser = new StreamedSource( reader );
 iterator = parser.iterator();
 writer = new StringWriter();
 buffer = writer.getBuffer();
 offset = 0;
}

代码示例来源:origin: org.apache.knox/gateway-server

@Override
public void store( GatewayDescriptor descriptor, Writer writer ) throws IOException {
 try {
  Document document = XmlUtils.createDocument();
  Element gateway = document.createElement( GATEWAY );
  document.appendChild( gateway );
  for( ResourceDescriptor resource : descriptor.resources() ) {
   gateway.appendChild( createResource( document, resource ) );
  }
  XmlUtils.writeXml( document, writer );
 } catch( ParserConfigurationException e ) {
  throw new IOException( e );
 } catch( TransformerException e ) {
  throw new IOException( e );
 }
}

代码示例来源:origin: apache/knox

@Override
public void store( GatewayDescriptor descriptor, Writer writer ) throws IOException {
 try {
  Document document = XmlUtils.createDocument();
  Element gateway = document.createElement( GATEWAY );
  document.appendChild( gateway );
  for( ResourceDescriptor resource : descriptor.resources() ) {
   gateway.appendChild( createResource( document, resource ) );
  }
  XmlUtils.writeXml( document, writer );
 } catch( ParserConfigurationException | TransformerException e ) {
  throw new IOException( e );
 }
}

代码示例来源:origin: org.apache.knox/gateway-server

private void mergeWebXmlOverrides( File webInfDir ) throws IOException, SAXException, ParserConfigurationException, TransformerException {
 File webXmlFile = new File( webInfDir, "web.xml" );
 Document webXmlDoc;
 if( webXmlFile.exists() ) {
  // Backup original web.xml file.
  File originalWebXmlFile = new File( webInfDir, "original-web.xml" );
  FileUtils.copyFile( webXmlFile, originalWebXmlFile );
  webXmlDoc = XmlUtils.readXml( webXmlFile );
 } else {
  webXmlDoc = XmlUtils.createDocument();
  webXmlDoc.appendChild( webXmlDoc.createElement( "web-app" ) );
 }
 File overrideWebXmlFile = new File( webInfDir, "override-web.xml" );
 if( overrideWebXmlFile.exists() ) {
  Document overrideWebXmlDoc = XmlUtils.readXml( overrideWebXmlFile );
  Element originalRoot = webXmlDoc.getDocumentElement();
  Element overrideRoot = overrideWebXmlDoc.getDocumentElement();
  NodeList overrideNodes = overrideRoot.getChildNodes();
  for( int i = 0, n = overrideNodes.getLength(); i < n; i++ ) {
   Node overrideNode = overrideNodes.item( i );
   if( overrideNode.getNodeType() == Node.ELEMENT_NODE ) {
    Node importedNode = webXmlDoc.importNode( overrideNode, true );
    originalRoot.appendChild( importedNode );
   }
  }
  
  XmlUtils.writeXml( webXmlDoc, new OutputStreamWriter(new FileOutputStream(webXmlFile), StandardCharsets.UTF_8) );
 }
}

代码示例来源:origin: org.apache.knox/gateway-provider-rewrite

private void processStartDocument( StartDocument event ) throws ParserConfigurationException {
 //System.out.println( "SD=" + event );
 String s;
 document = XmlUtils.createDocument( false );
 pushLevel( null, event, document, document, config );
 writer.write( "<?xml" );
 s = event.getVersion();
 if( s == null ) {
  s = DEFAULT_XML_VERSION;
 }
 writer.write( " version=\"");
 writer.write( s );
 writer.write( "\"" );
 s = event.getCharacterEncodingScheme();
 if( s != null ) {
  writer.write( " encoding=\"");
  writer.write( s );
  writer.write( "\"" );
 }
 writer.write( " standalone=\"");
 writer.write( event.isStandalone() ? "yes" : "no" );
 writer.write( "\"" );
 writer.write( "?>" );
}

代码示例来源:origin: apache/knox

webXmlDoc = XmlUtils.readXml( webXmlFile );
} else {
 webXmlDoc = XmlUtils.createDocument();
 webXmlDoc.appendChild( webXmlDoc.createElement( "web-app" ) );

代码示例来源:origin: apache/knox

private void processStartDocument( StartDocument event ) throws ParserConfigurationException {
 String s;
 document = XmlUtils.createDocument( false );
 pushLevel( null, document, document, config );
 writer.write( "<?xml" );
 s = event.getVersion();
 if( s == null ) {
  s = DEFAULT_XML_VERSION;
 }
 writer.write( " version=\"");
 writer.write( s );
 writer.write( "\"" );
 s = event.getCharacterEncodingScheme();
 if( s != null ) {
  writer.write( " encoding=\"");
  writer.write( s );
  writer.write( "\"" );
 }
 writer.write( " standalone=\"");
 writer.write( event.isStandalone() ? "yes" : "no" );
 writer.write( "\"" );
 writer.write( "?>" );
}

代码示例来源:origin: org.apache.knox/gateway-shell

@Override
 public Response call() throws Exception {
  Document document = XmlUtils.createDocument();
  Element root = document.createElement( ELEMENT_CELL_SET );
  document.appendChild( root );
  Element row = document.createElement( ELEMENT_ROW );
  row.setAttribute( ATTRIBUTE_KEY, Base64.encodeBase64String( rowId.getBytes( StandardCharsets.UTF_8 ) ) );
  root.appendChild( row );
  for( InsertableColumn column : columns ) {
   Element cell = document.createElement( ELEMENT_CELL );
   cell.setAttribute( ATTRIBUTE_COLUMN, column.encodedName() );
   if( column.time() != null ) {
    cell.setAttribute( ATTRIBUTE_TIMESTAMP, column.time().toString() );
   }
   cell.setTextContent( column.encodedValue() );
   row.appendChild( cell );
  }
  StringWriter writer = new StringWriter();
  Transformer t = XmlUtils.getTransformer( true, false, 0, false );
  XmlUtils.writeXml( document, writer, t );
  URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/false-row-key" );
  HttpPost request = new HttpPost( uri.build() );
  HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", StandardCharsets.UTF_8 ) );
  request.setEntity( entity );
  return new Response( execute( request ) );
 }
};

代码示例来源:origin: org.apache.knox/gateway-shell

@Override
public Response call() throws Exception {
 Document document = XmlUtils.createDocument();

代码示例来源:origin: org.apache.knox/gateway-shell

@Override
 public Response call() throws Exception {
  Document document = XmlUtils.createDocument();
  Element root = document.createElement( ELEMENT_TABLE_SCHEMA );
  document.appendChild( root );
  for( Family<Request> family : families ) {
   Element columnSchema = document.createElement( ELEMENT_COLUMN_SCHEMA );
   columnSchema.setAttribute( ATTRIBUTE_NAME, family.name() );
   for( Attribute attribute : family.attributes() ) {
    columnSchema.setAttribute( attribute.getName(), attribute.getValue().toString() );
   }
   root.appendChild( columnSchema );
  }
  StringWriter writer = new StringWriter();
  Transformer t = XmlUtils.getTransformer( true, false, 0, false );
  XmlUtils.writeXml( document, writer, t );
  URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/schema" );
  HttpPost request = new HttpPost( uri.build() );
  HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", StandardCharsets.UTF_8 ) );
  request.setEntity( entity );
  return new Response( execute( request ) );
 }
};

代码示例来源:origin: apache/knox

@Override
 public Response call() throws Exception {
  Document document = XmlUtils.createDocument();
  Element root = document.createElement( ELEMENT_CELL_SET );
  document.appendChild( root );
  Element row = document.createElement( ELEMENT_ROW );
  row.setAttribute( ATTRIBUTE_KEY, Base64.encodeBase64String( rowId.getBytes( StandardCharsets.UTF_8 ) ) );
  root.appendChild( row );
  for( InsertableColumn column : columns ) {
   Element cell = document.createElement( ELEMENT_CELL );
   cell.setAttribute( ATTRIBUTE_COLUMN, column.encodedName() );
   if( column.time() != null ) {
    cell.setAttribute( ATTRIBUTE_TIMESTAMP, column.time().toString() );
   }
   cell.setTextContent( column.encodedValue() );
   row.appendChild( cell );
  }
  StringWriter writer = new StringWriter();
  Transformer t = XmlUtils.getTransformer( true, false, 0, false );
  XmlUtils.writeXml( document, writer, t );
  URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/false-row-key" );
  HttpPost request = new HttpPost( uri.build() );
  HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", StandardCharsets.UTF_8 ) );
  request.setEntity( entity );
  return new Response( execute( request ) );
 }
};

代码示例来源:origin: apache/knox

@Override
 public Response call() throws Exception {
  Document document = XmlUtils.createDocument();
  Element root = document.createElement( ELEMENT_TABLE_SCHEMA );
  document.appendChild( root );
  for( Family<Request> family : families ) {
   Element columnSchema = document.createElement( ELEMENT_COLUMN_SCHEMA );
   columnSchema.setAttribute( ATTRIBUTE_NAME, family.name() );
   for( Attribute attribute : family.attributes() ) {
    columnSchema.setAttribute( attribute.getName(), attribute.getValue().toString() );
   }
   root.appendChild( columnSchema );
  }
  StringWriter writer = new StringWriter();
  Transformer t = XmlUtils.getTransformer( true, false, 0, false );
  XmlUtils.writeXml( document, writer, t );
  URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/schema" );
  HttpPost request = new HttpPost( uri.build() );
  HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", StandardCharsets.UTF_8 ) );
  request.setEntity( entity );
  return new Response( execute( request ) );
 }
};

代码示例来源:origin: org.apache.knox/gateway-shell

@Override
 public Response call() throws Exception {
  Document document = XmlUtils.createDocument();
  Element root = document.createElement( ELEMENT_TABLE_SCHEMA );
  root.setAttribute( ATTRIBUTE_NAME, tableName );
  for( Attribute attribute : attributes ) {
   root.setAttribute( attribute.getName(), attribute.getValue().toString() );
  }
  document.appendChild( root );
  for( Family<Request> family : families ) {
   Element columnSchema = document.createElement( ELEMENT_COLUMN_SCHEMA );
   columnSchema.setAttribute( ATTRIBUTE_NAME, family.name() );
   for( Attribute attribute : family.attributes() ) {
    columnSchema.setAttribute( attribute.getName(), attribute.getValue().toString() );
   }
   root.appendChild( columnSchema );
  }
  StringWriter writer = new StringWriter();
  Transformer t = XmlUtils.getTransformer( true, false, 0, false );
  XmlUtils.writeXml( document, writer, t );
  URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/schema" );
  HttpPut request = new HttpPut( uri.build() );
  HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", StandardCharsets.UTF_8 ) );
  request.setEntity( entity );
  return new Response( execute( request ) );
 }
};

代码示例来源:origin: apache/knox

@Override
 public Response call() throws Exception {
  Document document = XmlUtils.createDocument();
  Element root = document.createElement( ELEMENT_TABLE_SCHEMA );
  root.setAttribute( ATTRIBUTE_NAME, tableName );
  for( Attribute attribute : attributes ) {
   root.setAttribute( attribute.getName(), attribute.getValue().toString() );
  }
  document.appendChild( root );
  for( Family<Request> family : families ) {
   Element columnSchema = document.createElement( ELEMENT_COLUMN_SCHEMA );
   columnSchema.setAttribute( ATTRIBUTE_NAME, family.name() );
   for( Attribute attribute : family.attributes() ) {
    columnSchema.setAttribute( attribute.getName(), attribute.getValue().toString() );
   }
   root.appendChild( columnSchema );
  }
  StringWriter writer = new StringWriter();
  Transformer t = XmlUtils.getTransformer( true, false, 0, false );
  XmlUtils.writeXml( document, writer, t );
  URIBuilder uri = uri( HBase.SERVICE_PATH, "/", tableName, "/schema" );
  HttpPut request = new HttpPut( uri.build() );
  HttpEntity entity = new StringEntity( writer.toString(), ContentType.create( "text/xml", StandardCharsets.UTF_8 ) );
  request.setEntity( entity );
  return new Response( execute( request ) );
 }
};

代码示例来源:origin: apache/knox

public static void store(HaDescriptor descriptor, Writer writer) throws IOException {
 try {
   Document document = XmlUtils.createDocument();

代码示例来源:origin: org.apache.knox/gateway-provider-ha

public static void store(HaDescriptor descriptor, Writer writer) throws IOException {
 try {
   Document document = XmlUtils.createDocument();

代码示例来源:origin: apache/knox

@Override
public void store( UrlRewriteRulesDescriptor descriptor, Writer writer ) throws IOException {
 try {
  Document document = XmlUtils.createDocument();

代码示例来源:origin: org.apache.knox/gateway-provider-rewrite

@Override
public void store( UrlRewriteRulesDescriptor descriptor, Writer writer ) throws IOException {
 try {
  Document document = XmlUtils.createDocument();

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com