Firebase数据库云功能对删除事件的影响

时间:2017-06-20 18:48:25

标签: android firebase firebase-realtime-database google-cloud-functions

我希望在从某个表中删除值后运行云功能。 我查看了文档(https://firebase.google.com/docs/functions/database-events),但没有找到与我的问题相关的任何内容。

Firebase的云功能是否支持这样的事情?

1 个答案:

答案 0 :(得分:2)

您应该可以使用以下内容:

public class Run {
    public static void main(String[] args){
        Parser parser = new Parser();
        ImageManager imageManager = new ImageManager();
        imageManager.addImage("title", "location","description");
        parser.parsePictureData();
        imageManager.getImages();
    }
}

public class Parser {

ImageManager imageManager = new ImageManager();
Document document;

public void parsePictureData() {
    try{
        readXMLFile();
        readImageFromDocument();
    }catch(IOException e){
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    }
}

private void readXMLFile() throws IOException, SAXException, ParserConfigurationException {
    File file = new File(System.getProperty("user.dir")+"/src/"+"test.xml");
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse(file);
}

private void readImageFromDocument() {
    NodeList pictureNodes = document.getElementsByTagName("picture");
    for(int i = 0; i<pictureNodes.getLength();i++){
        Node pictureNode = pictureNodes.item(i);
        if(pictureNode.getNodeType()==Node.ELEMENT_NODE){
            Element pictureElement = (Element) pictureNode;
            String location =pictureElement.getAttribute("location");
            String imagePath = pictureElement.getElementsByTagName("path").item(0).getTextContent();
            String title = pictureElement.getElementsByTagName("title").item(0).getTextContent();
            String description = pictureElement.getElementsByTagName("description").item(0).getTextContent();

            imageManager.addImage(title,location,description);
        }
    }
}

}

public class ImageManager {

ArrayList<Pictures> images = new ArrayList<>();

public void addImage(String title,  String location, String description){
    Pictures newImage = new Pictures(title, location, description);
    images.add(newImage);
    System.out.println("1"+images);
}

public ArrayList<Pictures> getImages(){
    System.out.println("2"+images);
    return images;
}

}

public class Pictures{

private String title;
private String location;
private String description;


public Pictures(String title, String location, String description){
    this.title = title;
    this.location = location;
    this.description = description;
}
}